diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index e09e276b4f5f3a6b03e3d47d2f317084a0ddecb1..110e3db1aac3bb7bc531202aa1c527e8bc12f419 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -164,7 +164,8 @@ Control { var get = model['get']; if (!get && popup.__modelIsArray) { - get = function(i) { return model[i]; } + if (model[0].constructor !== String) // arrays of strings don't have textRole + get = function(i) { return model[i]; } } var modelMayHaveRoles = get !== undefined diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index fc1353544188167c136241dd10f2d3d28cf26218..d3bd2791692e39c1b1e326e17b41dd45e708244b 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -133,6 +133,16 @@ TestCase { comboBox.destroy() } + function test_arrayModelWithoutTextRole() { + var arrayModel = ['Banana', 'Coconut', 'Apple'] + + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox {}', testCase, ''); + comboBox.model = arrayModel + compare(comboBox.currentIndex, 0) + compare(comboBox.currentText, "Banana") + comboBox.destroy() + } + function test_activeFocusOnTab() { var test_control = 'import QtQuick 2.1; \ import QtQuick.Controls 1.0; \