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

QComboBox will emit currentIndexChanged when the index isn't changed

    XMLWordPrintable

Details

    • Windows
    • c4b62ee50 (dev), 0f664ee6e (6.5), 4e927c639 (tqtc/lts-6.2)

    Description

      This is a regression from QTBUG-103007. In cases where the combo box's model has been modified each subsequent call to setCurrentIndex(-1) will emit a currentIndexChanged signal.

      	QStandardItemModel model;
      	model.appendRow(new QStandardItem("a"));
      	model.appendRow(new QStandardItem("b"));
      
      	QComboBox combo;
      	combo.setModel(&model);
      	QSignalSpy spy(&combo, QOverload<int>::of(&QComboBox::currentIndexChanged));
      
      	combo.setCurrentIndex(-1);
      	QCOMPARE(spy.count(), 1);
      
      	//Setting it to the same thing shouldn't emit currentIndexChanged
      	combo.setCurrentIndex(-1);
      	QCOMPARE(spy.count(), 1);
      
      	combo.setCurrentIndex(1);
      	QCOMPARE(spy.count(), 2);
      
      	//This will set "indexBeforeChange" to 1. It won't change until we update the model again
      	model.appendRow(new QStandardItem("c"));
      
      	combo.setCurrentIndex(-1);
      	QCOMPARE(spy.count(), 3);
      
      	//Because of QTBUG-103007 it will emit currentIndexChanged now. It didn't in QT5.
      	combo.setCurrentIndex(-1);
      	QCOMPARE(spy.count(), 3);
      

      Attachments

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

        Activity

          People

            axelspoerl Axel Spoerl
            noah Noah Hamerslough
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes