diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2023-10-20 14:54:06 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-10-24 22:10:43 +0200 |
commit | 2d59f2e8caed71d4eceb1abe3ce17b7befb40559 (patch) | |
tree | 1692790107f630edaa510c54bdc594cb006fae73 /src/widgets/dialogs | |
parent | 9c8651478b482cb162a6fd92bb79f0d7f6a2573c (diff) |
QMessageBox: Fall back to non-native dialog if button has menu
There's no plumbing in QMessageDialogOptions for supporting
native dialog buttons with menus, and even if there was such
plumbing, we don't know if our native dialogs could support
them.
As a workaround, detect the situation and automatically fall
back to the non-native dialog, so the user doesn't need to
set Qt::AA_DontUseNativeDialogs explicitly.
Fixes: QTBUG-118419
Change-Id: Iece7012909261b8869ce0ca23e45e8daaf4babc7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qmessagebox.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index bb71a2370e..5d0c84e9d4 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -2824,6 +2824,14 @@ bool QMessageBoxPrivate::canBeNativeDialog() const if (strcmp(QMessageBox::staticMetaObject.className(), q->metaObject()->className()) != 0) return false; + for (auto *customButton : customButtonList) { + if (QPushButton *pushButton = qobject_cast<QPushButton *>(customButton)) { + // We can't support buttons with menus in native dialogs (yet) + if (pushButton->menu()) + return false; + } + } + return QDialogPrivate::canBeNativeDialog(); } |