diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2019-12-06 13:13:51 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2019-12-10 12:40:32 +0100 |
commit | cb1c3528078659c297fb12ea6914978cec1d2614 (patch) | |
tree | 0327c155724c25e331b08d835360c191f64c55f9 /src | |
parent | aaec25a798352fc222f86ab3b299384575f51dc8 (diff) |
ComboBox: change currentIndex (if applicable) when focus is lost
When the user enters text into an editable ComboBox that matches
the text of an entry in the model, and then tabs out to another
item, the currentIndex should be changed to that entry.
This brings the behavior of ComboBox in line with QComboBox.
Change-Id: Ibb1e201a503704681ebcbc7135d1964cc1f6bbca
Fixes: QTBUG-78885
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 86150a0f..7833b39b 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -1730,6 +1730,12 @@ bool QQuickComboBox::eventFilter(QObject *object, QEvent *event) // the user clicked on the popup button to open it, not close it). d->hidePopup(false); setPressed(false); + + // The focus left the text field, so if the edit text matches an item in the model, + // change our currentIndex to that. This matches widgets' behavior. + const int indexForEditText = find(d->extra.value().editText, Qt::MatchFixedString); + if (indexForEditText > -1) + setCurrentIndex(indexForEditText); } break; #if QT_CONFIG(im) |