diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-12-29 13:24:34 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2020-01-28 06:24:26 +0100 |
commit | b0c804f345a383d2813f4709632baa43a4275646 (patch) | |
tree | 5b522423ee7cb3475e26112950ed00086a0ef6e7 /tests/auto/widgets | |
parent | fb7c9dfc060a09b4b1fa6d474f106bb6c1d2d4df (diff) |
QComboBox: unify behavior of setModel() and modelReset
When a new model is set, a valid index is selected. When a model is
reset, this is not the case which is slightly inconsistent. Fix it by
using the same logic to find a valid index when the model is reset
Fixes: QTBUG-80998
Change-Id: I6c167511e199a6664343cf1dc3bcd27c65389bfd
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index ea1b330152..3878e7ccb2 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2756,10 +2756,7 @@ void tst_QComboBox::resetModel() class StringListModel : public QStringListModel { public: - StringListModel(const QStringList &list) : QStringListModel(list) - { - } - + using QStringListModel::QStringListModel; void reset() { QStringListModel::beginResetModel(); @@ -2767,8 +2764,8 @@ void tst_QComboBox::resetModel() } }; QComboBox cb; - StringListModel model( QStringList() << "1" << "2"); - QSignalSpy spy(&cb, SIGNAL(currentIndexChanged(int))); + StringListModel model({"1", "2"}); + QSignalSpy spy(&cb, QOverload<int>::of(&QComboBox::currentIndexChanged)); QCOMPARE(spy.count(), 0); QCOMPARE(cb.currentIndex(), -1); //no selection @@ -2779,7 +2776,7 @@ void tst_QComboBox::resetModel() model.reset(); QCOMPARE(spy.count(), 2); - QCOMPARE(cb.currentIndex(), -1); //no selection + QCOMPARE(cb.currentIndex(), 0); //first item selected } |