From 392d520ade77e6fb941e54fdaa8b23d34c745a8b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sun, 17 Apr 2016 19:28:17 +0200 Subject: 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 --- src/quicktemplates2/qquickcombobox.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') 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(d->delegateModel)->componentComplete(); if (count() > 0) { - if (d->currentIndex == -1) + if (!d->hasCurrentIndex && d->currentIndex == -1) setCurrentIndex(0); else d->updateCurrentText(); -- cgit v1.2.3