summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-05-03 17:59:48 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-05-04 19:40:32 +0200
commita43ca591c1835c27fd2acd63298c42f51b470f8e (patch)
tree3a0992f2a41aa639a850e1280919d84e9ed39c50 /src/widgets
parent3dd3268ded4dd74c64d7ec726fd534375ab9f018 (diff)
Fix hiding in QComboBox when there is no selection
If there is an effect on the selected item we want to show it, but if there is no item to highligh we just close the combo. Fixes: QTBUG-113311 Pick-to: 6.5 Change-Id: I287af75d27e6f6ff969e4706e16cc8c4812129ea Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qcombobox.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index fabd4e9eed..33aa88fffb 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -2809,31 +2809,30 @@ void QComboBox::hidePopup()
return;
#if QT_CONFIG(effects)
- // Flash selected/triggered item (if any).
- if (style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem)) {
- QItemSelectionModel *selectionModel = d->container->itemView()
- ? d->container->itemView()->selectionModel() : nullptr;
- if (selectionModel && selectionModel->hasSelection()) {
- const QItemSelection selection = selectionModel->selection();
-
- QTimer::singleShot(0, d->container, [d, selection, selectionModel]{
+ QItemSelectionModel *selectionModel = d->container->itemView()
+ ? d->container->itemView()->selectionModel() : nullptr;
+ // Flash selected/triggered item (if any) before hiding the popup.
+ if (style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem) &&
+ selectionModel && selectionModel->hasSelection()) {
+ const QItemSelection selection = selectionModel->selection();
+
+ QTimer::singleShot(0, d->container, [d, selection, selectionModel]{
+ QSignalBlocker modelBlocker(d->model);
+ QSignalBlocker viewBlocker(d->container->itemView());
+ QSignalBlocker containerBlocker(d->container);
+
+ // Deselect item and wait 60 ms.
+ selectionModel->select(selection, QItemSelectionModel::Toggle);
+ QTimer::singleShot(60, d->container, [d, selection, selectionModel]{
QSignalBlocker modelBlocker(d->model);
QSignalBlocker viewBlocker(d->container->itemView());
QSignalBlocker containerBlocker(d->container);
-
- // Deselect item and wait 60 ms.
selectionModel->select(selection, QItemSelectionModel::Toggle);
- QTimer::singleShot(60, d->container, [d, selection, selectionModel]{
- QSignalBlocker modelBlocker(d->model);
- QSignalBlocker viewBlocker(d->container->itemView());
- QSignalBlocker containerBlocker(d->container);
- selectionModel->select(selection, QItemSelectionModel::Toggle);
- QTimer::singleShot(20, d->container, [d] {
- d->doHidePopup();
- });
+ QTimer::singleShot(20, d->container, [d] {
+ d->doHidePopup();
});
});
- }
+ });
} else
#endif // QT_CONFIG(effects)
{