Reputation: 10415
I used below syntax in Qt5 according to new connect syntax to avoid type mismatches of slot and signals for a a QListWidget
with checkable items.
connect(item, &QListWidget::itemChanged,this , &mainWindow::checkItemChanged);
I want to run my slot in case any of list item changed its state. In order to this this I used itemChanged
signal due to this answer, but it is protected and compile time error raise as below:
error: ‘void QListWidget::itemChanged(QListWidgetItem*)’ is protected
How can I handles this? Should I subclass my own QListWidget
or there are some other solutions to this?
Upvotes: 2
Views: 1114
Reputation: 10079
You can use the more appropriate syntax according to Qt version:
#if QT_VERSION >= 0x050000
connect(item, &QListWidget::itemChanged, this , &MainWindow::checkItemChanged);
#else
connect(item, SIGNAL(checkItemChanged), this , SLOT(checkItemChanged));
#endif
(or the 'old string-based' for all versions).
Upvotes: 2