Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
5.9.0, 5.12.1
-
616c430d2b7f36e70987df7b2dc97e71f0e8b589 (qt/qtquickcontrols2/5.12)
Description
When inputting and confirming (Return or Enter) a string which is not contained in the model of an editable ComboBox, the currentIndex and currentText will stay unchanged (Banana is the first item in the model and thus selected by default).
editText: Test currentText: Banana currentIndex: 0
What should happen is that the currentIndex should be set to -1 and the currentText should probably be set to the confirmed string (look at the documentation snippet below).
To get the proper behavior the user has to confirm the input a second time.
editText: Test currentText: currentIndex: -1
Even though the currentIndex is set correctly after the second confirmation, the currentText is empty , but this might be intended.
The ComboBox documentation contains the following statement
This signal is emitted when the Return or Enter key is pressed on an editable combo box. If the confirmed string is not currently in the model, the currentIndex will be set to -1 and the currentText will be updated accordingly.
ComboBox { editable: true model: ["Banana", "Apple", "Coconut", "Kiwi", "Mango #5", "Pomelo"] anchors.top: parent.top anchors.topMargin: 10 anchors.horizontalCenter: parent.horizontalCenter onEditTextChanged: console.log("onEditTextChanged: " + editText) onAccepted: console.log("onAccepted.\neditText: " + editText +"\ncurrentText: " + currentText + "\ncurrentIndex: " + currentIndex) }
The following snippet shows the console output of the ComboBox code above. The user entered Test and hit enter twice.
qml: onEditTextChanged: Banana qml: onEditTextChanged: T qml: onEditTextChanged: Te qml: onEditTextChanged: Tes qml: onEditTextChanged: Test qml: onAccepted. editText: Test currentText: Banana currentIndex: 0 qml: onAccepted. editText: Test currentText: currentIndex: -1
Attachments
For Gerrit Dashboard: QTBUG-75338 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
260417,4 | ComboBox: document the behavior surrounding the accepted() signal | 5.12 | qt/qtquickcontrols2 | Status: MERGED | +2 | 0 |