QTreeWidget fails to emit itemClicked signal.
I am attempting to control a QStackedWidget with a QTreeWidget.
Both are initialized in the constructor of my class.
To do so, I use the following code:
Code:
//optionLabels is a QTreeWidget*
//optionControls is a QStackedWidget*
void EditOptionsDialog::makeConnections() {
}
//This is defined as a slot in the header file
void EditOptionsDialog
::changeCollectionPane(QTreeWidgetItem* selection,
int col
) { QMessageBox::information(this, tr
("Is this slot called?"), tr
("Index of Clicked Widget: %1").
arg(selection
->data
(col, Qt
::UserRole).
toInt()));
if(selection && col == 0) {
optionControls->setCurrentIndex(selection->data(col, Qt::UserRole).toInt());
}
}
When I click around on the tree, I don't get a message box, so the slot is not being called. Any ideas as to why?
Re: QTreeWidget fails to emit itemClicked signal.
Did you remember do declared changeCollectionPane as a slot? Does the declaration of EditOptionsDialog contain required Q_OBJECT macro? Check the debug output for a detailed reason why QObject::connect() fails.
Re: QTreeWidget fails to emit itemClicked signal.
Thanks; I forgot that the Q_OBJECT macro still has to go in subclasses of standard Qt classes.