diff options
Diffstat (limited to 'src/widgets/widgets/qcombobox.cpp')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 331764efa8..5889545b1c 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -728,7 +728,8 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) default: #if QT_CONFIG(shortcut) if (keyEvent->matches(QKeySequence::Cancel)) { - combo->hidePopup(); + closeOnCancel = true; + keyEvent->accept(); return true; } #endif @@ -775,6 +776,7 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) void QComboBoxPrivateContainer::showEvent(QShowEvent *) { + closeOnCancel = true; combo->update(); } @@ -3216,6 +3218,12 @@ void QComboBox::keyPressEvent(QKeyEvent *e) break; #endif default: + if (e->matches(QKeySequence::Cancel) && (!d->container || d->container->closeOnCancel)) { + hidePopup(); + e->accept(); + d->container->closeOnCancel = false; + } + if (!d->lineEdit) { if (!e->text().isEmpty()) d->keyboardSearchString(e->text()); |