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. Pick-to: 6.5 Fixes: QTBUG-118419 Change-Id: Iece7012909261b8869ce0ca23e45e8daaf4babc7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 2d59f2e8caed71d4eceb1abe3ce17b7befb40559) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
ba8b0fdcf7
commit
a69980e557
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user