Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-4454

[QComboBox] calling view() before setModel() breaks signal highlighted(int)

    XMLWordPrintable

Details

    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();
      }
      

      Attachments

        For Gerrit Dashboard: QTBUG-4454
        # Subject Branch Project Status CR V

        Activity

          People

            stephen.kelly Stephen Kelly (Unused account) (Inactive)
            mpejcoch Martin Pejcoch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes