diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-04-17 19:28:17 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-04-18 09:48:40 +0000 |
commit | 392d520ade77e6fb941e54fdaa8b23d34c745a8b (patch) | |
tree | 46991b006ef4da4227a79b18f5b72799ec3efcee /src | |
parent | 34c43df77dbd29eeb7e9ea34b23cad7fb80c735c (diff) |
ComboBox: respect currentIndex:-1
Don't override explicitly set current index in Component.onCompleted.
Task-number: QTBUG-52615
Change-Id: If5ce4ec1db29f8ac94d457d297910d61fb0b8a18
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index e10a8b48..766cabe8 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -154,7 +154,7 @@ class QQuickComboBoxPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickComboBox) public: - QQuickComboBoxPrivate() : pressed(false), ownModel(false), hasDisplayText(false), + QQuickComboBoxPrivate() : pressed(false), ownModel(false), hasDisplayText(false), hasCurrentIndex(false), highlightedIndex(-1), currentIndex(-1), delegateModel(nullptr), delegate(nullptr), popup(nullptr) { } @@ -177,6 +177,7 @@ public: bool pressed; bool ownModel; bool hasDisplayText; + bool hasCurrentIndex; int highlightedIndex; int currentIndex; QVariant model; @@ -479,6 +480,7 @@ int QQuickComboBox::currentIndex() const void QQuickComboBox::setCurrentIndex(int index) { Q_D(QQuickComboBox); + d->hasCurrentIndex = true; if (d->currentIndex == index) return; @@ -857,7 +859,7 @@ void QQuickComboBox::componentComplete() static_cast<QQmlDelegateModel *>(d->delegateModel)->componentComplete(); if (count() > 0) { - if (d->currentIndex == -1) + if (!d->hasCurrentIndex && d->currentIndex == -1) setCurrentIndex(0); else d->updateCurrentText(); |