diff options
| -rw-r--r-- | src/controls/ComboBox.qml | 2 | ||||
| -rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 509a4b3d8..3463470f1 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -642,7 +642,7 @@ Control { var selectedItem; if (__selectedIndex !== -1 && (selectedItem = items[__selectedIndex])) { input.editTextMatches = true - selectedText = selectedItem.text + selectedText = Qt.binding(function () { return 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 b6eaaf6dd..af1fc9dda 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -743,5 +743,16 @@ TestCase { test.destroy() } + + function test_modelDataChange() { + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.2 ; ComboBox {}', testCase, ''); + comboBox.textRole = "text" + comboBox.model = model + compare(comboBox.currentIndex, 0) + compare(comboBox.currentText, "Banana") + model.set(0, { text: "Pomegranate", color: "Yellow" }) + compare(comboBox.currentText, "Pomegranate") + comboBox.destroy() + } } } |
