summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-04-10 16:46:10 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-28 13:34:24 +0200
commit7b5c79df9b5e6eea40bee48f188771fd19198893 (patch)
treedabb718c2365f0447235be82885297049b681217
parent38be2edc660e137ae549eb91d27cf1d14234149e (diff)
downloadqtquickcontrols-7b5c79df9b5e6eea40bee48f188771fd19198893.tar.gz
ComboBox: Update currentText when currentIndex goes from -1 to 0
We need to help things a bit because the internal selectedText property won't change in that specific case. Task-number: QTBUG-38036 Change-Id: Id997da97a77faad8ffaad08e8b9c7614d8b6b7fc Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Caroline Chao <caroline.chao@digia.com>
-rw-r--r--src/controls/ComboBox.qml2
-rw-r--r--tests/auto/controls/data/tst_combobox.qml14
2 files changed, 16 insertions, 0 deletions
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml
index c130abe8..16489118 100644
--- a/src/controls/ComboBox.qml
+++ b/src/controls/ComboBox.qml
@@ -586,6 +586,8 @@ Control {
if (__selectedIndex !== -1 && (selectedItem = items[__selectedIndex])) {
input.editTextMatches = true
selectedText = selectedItem.text
+ if (currentText !== selectedText) // __selectedIndex went form -1 to 0
+ selectedTextChanged()
}
}
}
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index 8910a30e..2052e676 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -698,6 +698,20 @@ TestCase {
}
}
+ function test_minusOneToZeroSelection_QTBUG_38036() {
+ var qmlObject = 'import QtQuick.Controls 1.2 ; ComboBox { model: ["A", "B", "C"] }'
+ var comboBox = Qt.createQmlObject(qmlObject, testCase, '');
+ compare(comboBox.currentIndex, 0)
+ compare(comboBox.currentText, "A")
+ comboBox.currentIndex = -1
+ compare(comboBox.currentIndex, -1)
+ compare(comboBox.currentText, "")
+ comboBox.currentIndex = 0
+ compare(comboBox.currentIndex, 0)
+ compare(comboBox.currentText, "A")
+ comboBox.destroy()
+ }
+
function test_keys() {
var component = Qt.createComponent("combobox/cb_keys.qml")
compare(component.status, Component.Ready)