I'm new to QT, and it's hard for me to understand how the QTableView change signal is handled. I have a window with openGL and QTableView widgets. I have a data model class that populates the table view correctly, so I added a public slot to this class:
class APartsTableModel : public QAbstractTableModel { public: AVehicleModel *vehicle; explicit APartsTableModel(QObject *parent = 0);
When I am ready to show a window with a table view, I select / initialize it as follows:
//create the display view AStarModelView *displayWindow = new AStarModelView(this, starModel->vehicle); //create the datamodel for the table view APartsTableModel *dataModel = new APartsTableModel(displayWindow); dataModel->vehicle = starModel->vehicle; //create selection model for table view QItemSelectionModel *selModel = new QItemSelectionModel(dataModel); displayWindow->materialsTable->setSelectionModel(selModel); //setup model and signal displayWindow->materialsTable->setModel(dataModel); connect(selModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), dataModel, SLOT(selectionChangedSlot(const QItemSelection &, const QItemSelection &))); //show the view displayWindow->show();
When I set a breakpoint when implementing a slot function, I never hit it. I also tried not to allocate a new QItemSelectionModel , but that didn't work either. I'm really not sure what I'm doing wrong here.
Jeffw source share