diff options
Diffstat (limited to 'src/quicktemplates2/qquickcombobox.cpp')
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 21eecfe1..7833b39b 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype ComboBox \inherits Control - \instantiates QQuickComboBox +//! \instantiates QQuickComboBox \inqmlmodule QtQuick.Controls \since 5.7 \ingroup qtquickcontrols2-input @@ -472,7 +472,7 @@ void QQuickComboBoxPrivate::updateCurrentText(bool hasDelegateModelObject) if (currentText != text) { currentText = text; if (!hasDisplayText) - q->setAccessibleName(text); + q->maybeSetAccessibleName(text); emit q->currentTextChanged(); } if (!hasDisplayText && displayText != text) { @@ -1051,7 +1051,7 @@ void QQuickComboBox::setDisplayText(const QString &text) return; d->displayText = text; - setAccessibleName(text); + maybeSetAccessibleName(text); emit displayTextChanged(); } @@ -1636,7 +1636,7 @@ QString QQuickComboBox::textAt(int index) const } /*! - \qmlmethod int QtQuick.Controls::ComboBox::find(string text, flags = Qt.MatchExactly) + \qmlmethod int QtQuick.Controls::ComboBox::find(string text, enumeration flags) Returns the index of the specified \a text, or \c -1 if no match is found. @@ -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) @@ -1970,7 +1976,7 @@ void QQuickComboBox::accessibilityActiveChanged(bool active) QQuickControl::accessibilityActiveChanged(active); if (active) { - setAccessibleName(d->hasDisplayText ? d->displayText : d->currentText); + maybeSetAccessibleName(d->hasDisplayText ? d->displayText : d->currentText); setAccessibleProperty("editable", isEditable()); } } |