summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-10-22 16:22:27 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-10-26 00:14:33 +0200
commitb0ddca18d73430771f52c034e3d5a1bb92363f64 (patch)
treea9535aefc597a055e3c8946c9a173f67858ee38b /src/widgets/dialogs
parent1b0e76f514e9a460e1d78a813813c0909838a03e (diff)
QMessageBox: Do last minute setup in setVisible instead of showEvent
The native message dialogs are shown in QMessageBox::setVisible, instead of plumbed via e.g. QWidgetPrivate::show_sys (which is not virtual). And we try to show the native dialog before we call the base class QDialog::setVisible(), where we end up sending the show event. As the native dialogs might rely on the last minute setup of adding an OK button or detecting the escape button, we need to do it in setVisible instead. We can not switch the order of showing the native dialogs after calling the base class setVisible (and getting showEvent), as we need to know whether the native dialog could be shown or not to decide whether to show the fallback widget dialog. The part from showEvent that added the detailsButton has been removed, as we're already doing that in setDetailsText(). Pick-to: 6.5 6.6 Change-Id: I23f1d87d542d9dadfd71924f8119c22720f4b276 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index ca7af90c15..ef1d8b04aa 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -1661,6 +1661,11 @@ void QMessageBoxPrivate::setVisible(bool visible)
{
Q_Q(QMessageBox);
+ // Last minute setup
+ if (autoAddOkButton)
+ q->addButton(QMessageBox::Ok);
+ detectEscapeButton();
+
if (canBeNativeDialog())
setNativeDialogVisible(visible);
@@ -1705,13 +1710,7 @@ QMessageBox::ButtonRole QMessageBox::buttonRole(QAbstractButton *button) const
void QMessageBox::showEvent(QShowEvent *e)
{
Q_D(QMessageBox);
- if (d->autoAddOkButton) {
- addButton(Ok);
- }
- if (d->detailsButton)
- addButton(d->detailsButton, QMessageBox::ActionRole);
d->clickedButton = nullptr;
- d->detectEscapeButton();
d->updateSize();
#if QT_CONFIG(accessibility)