Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.5.2, 4.6.3
-
None
Description
Calling view() on a QComboBox before setting a (custom) model on it
results in the highlighted signal no longer being emitted.
See the code below. If the call to view() is commented out, the
highlighted(int) signal is emitted again. If the call is executed before
the model is set, the signal is not emitted.
#include <QtGui> class MyApplication : public QApplication { Q_OBJECT public: MyApplication(int &argc, char **argv) : QApplication(argc, argv) {} public slots: void highlighted(int i) { qDebug() << i << "has been highlighted"; } }; #include "main.moc" int main(int argc, char **argv) { MyApplication app(argc, argv); QComboBox cob; app.connect(&cob, SIGNAL(highlighted(int)), SLOT(highlighted(int))); // Calling view() before setting the model makes highlighted() not work // (In a subclass of QComboBox I had a QAction added to the view(), // this resulted in the highlighted() signal no longer being emitted.) cob.view(); // comment this line to make the highlighted(int) signal work again QStandardItemModel sim; for(int i=0;i<5;i++) sim.appendRow(new QStandardItem(QString::number(i))); cob.setModel(&sim); cob.setModelColumn(0); cob.show(); return app.exec(); }