Doc: Add setModel(open) option to the documentation
Changed the Model Dialogs section adding open() function. Task-number: QTBUG-127777 Pick-to: 6.8 Change-Id: If5086f4e2226c4d032fe1bcfbf2ef550803973c8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 40f7454c919501f3c984c8fe4eeb379b360d4789) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d5c3460b41
commit
423659af18
@ -230,22 +230,30 @@ QVariant QDialogPrivate::styleHint(QPlatformDialogHelper::StyleHint hint) const
|
|||||||
the user to continue to use other windows in an application.
|
the user to continue to use other windows in an application.
|
||||||
|
|
||||||
The most common way to display a modal dialog is to call its
|
The most common way to display a modal dialog is to call its
|
||||||
exec() function. When the user closes the dialog, exec() will
|
\l open() function. Alternatively, you can call \l setModal(true) or
|
||||||
provide a useful \l{#return}{return value}. To close the dialog
|
\l setWindowModality(), and then \l show(). In both cases, once the dialog is
|
||||||
and return the appropriate value, you must connect a default button,
|
displayed, the control is immediately returned to the caller. You must connect
|
||||||
e.g. an \uicontrol OK button to the accept() slot and a
|
to the \l finished() signal to know when the dialog is closed and what its
|
||||||
\uicontrol Cancel button to the reject() slot. Alternatively, you
|
\l {#return} {return value} is. Alternatively, you can connect to the
|
||||||
can call the done() slot with \c Accepted or \c Rejected.
|
\l accepted() and \l rejected() signals.
|
||||||
|
|
||||||
An alternative is to call setModal(true) or setWindowModality(),
|
When implementing a custom dialog, to close the dialog and return an
|
||||||
then show(). Unlike exec(), show() returns control to the caller
|
appropriate value, connect a default button, for example, an OK button, to the
|
||||||
immediately. Calling setModal(true) is especially useful for
|
\l accept() slot, and a Cancel button to the \l reject() slot. Alternatively,
|
||||||
progress dialogs, where the user must have the ability to interact
|
you can call the \l done() slot with \c Accepted or \c Rejected.
|
||||||
with the dialog, e.g. to cancel a long running operation. If you
|
|
||||||
use show() and setModal(true) together to perform a long operation,
|
If you show the modal dialog to perform a long-running operation, it is
|
||||||
you must call QCoreApplication::processEvents() periodically during
|
recommended to perform the operation in a background worker thread, so that
|
||||||
processing to enable the user to interact with the dialog. (See
|
it does not interfere with the GUI thread.
|
||||||
QProgressDialog.)
|
|
||||||
|
\warning When using \l open() or \l show(), the modal dialog should not be
|
||||||
|
created on the stack, so that it does not get destroyed as soon as the control
|
||||||
|
returns to the caller.
|
||||||
|
|
||||||
|
\note There is a way to show a modal dialog in a blocking mode by calling
|
||||||
|
\l exec(). In this case, the control returns to the GUI thread only when the
|
||||||
|
dialog is closed. However, such approach is discouraged, because it creates a
|
||||||
|
nested event loop, which is not fully supported by some platforms.
|
||||||
|
|
||||||
\section1 Modeless Dialogs
|
\section1 Modeless Dialogs
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user