summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-11-14 18:42:48 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-11-16 15:17:19 +0100
commit91170aba0f465f9881483bcb93f319d608528002 (patch)
treecb61abebd3b27a5c9a18d7da9c61277af57e65c9 /src
parentbd7fa4a53791ead147393d3a4a797d2e14ee3343 (diff)
Update QMessageBox window modality documentation
Unlike a regular QWidget or QDialog, a QMessageBox is initialized to be application modal by default. Make sure we document this quirk for both of the QMessageBox constructors, and tell the user that it's possible to override this default. Add a note about open() and exec() coming with their own set of semantics when it comes to window modality. Change-Id: I37a429633cefec94f790d3b0b30d0a8995ef60ae Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 4b20a183ce..95aaf45e7c 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -780,14 +780,21 @@ void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button
*/
/*!
- Constructs a message box with no text and no buttons. \a parent is
- passed to the QDialog constructor.
+ Constructs an \l{Qt::ApplicationModal} {application modal} message box with no text and no buttons.
+ \a parent is passed to the QDialog constructor.
+
+ The window modality can be overridden via setWindowModality() before calling show().
+
+ \note Using open() or exec() to show the message box affects the window modality.
+ Please see the detailed documentation for each function for more information.
On \macos, if you want your message box to appear
as a Qt::Sheet of its \a parent, set the message box's
\l{setWindowModality()} {window modality} to Qt::WindowModal or use open().
Otherwise, the message box will be a standard dialog.
+ \sa setWindowTitle(), setText(), setIcon(), setStandardButtons(), setWindowModality()
+
*/
QMessageBox::QMessageBox(QWidget *parent)
: QDialog(*new QMessageBoxPrivate, parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
@@ -797,20 +804,22 @@ QMessageBox::QMessageBox(QWidget *parent)
}
/*!
- Constructs a message box with the given \a icon, \a title, \a
- text, and standard \a buttons. Standard or custom buttons can be
+ Constructs an \l{Qt::ApplicationModal} {application modal} message box with the given \a icon,
+ \a title, \a text, and standard \a buttons. Standard or custom buttons can be
added at any time using addButton(). The \a parent and \a f
arguments are passed to the QDialog constructor.
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
+ The window modality can be overridden via setWindowModality() before calling show().
+
+ \note Using open() or exec() to show the message box affects the window modality.
+ Please see the detailed documentation for each function for more information.
On \macos, if \a parent is not \nullptr and you want your message box
to appear as a Qt::Sheet of that parent, set the message box's
\l{setWindowModality()} {window modality} to Qt::WindowModal
(default). Otherwise, the message box will be a standard dialog.
- \sa setWindowTitle(), setText(), setIcon(), setStandardButtons()
+ \sa setWindowTitle(), setText(), setIcon(), setStandardButtons(), setWindowModality()
*/
QMessageBox::QMessageBox(Icon icon, const QString &title, const QString &text,
StandardButtons buttons, QWidget *parent,