PySide6.QtWidgets.QMessageBox¶
- class QMessageBox¶
The
QMessageBoxclass provides a modal dialog for informing the user or for asking the user a question and receiving an answer. More…Synopsis¶
Properties¶
detailedTextᅟ- The text to be displayed in the details areaiconᅟ- The message box’s iconiconPixmapᅟ- The current iconinformativeTextᅟ- The informative text that provides a fuller description for the messageoptionsᅟ- Options that affect the look and feel of the dialogstandardButtonsᅟ- Collection of standard buttons in the message boxtextᅟ- The message box text to be displayedtextFormatᅟ- The format of the text displayed by the message box
Methods¶
def
__init__()def
addButton()def
button()def
buttonRole()def
buttonText()def
buttons()def
checkBox()def
clickedButton()def
defaultButton()def
detailedText()def
escapeButton()def
icon()def
iconPixmap()def
open()def
options()def
removeButton()def
setButtonText()def
setCheckBox()def
setIcon()def
setIconPixmap()def
setOption()def
setOptions()def
setText()def
setTextFormat()def
setWindowTitle()def
standardButton()def
testOption()def
text()def
textFormat()
Signals¶
def
buttonClicked()
Static functions¶
def
about()def
aboutQt()def
critical()def
information()def
question()def
standardIcon()def
warning()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
A message box displays a primary
textto alert the user to a situation, aninformative textto further explain the situation, and an optionaldetailed textto provide even more data if the user requests it.A message box can also display an
iconandstandard buttonsfor accepting a user response.Two APIs for using
QMessageBoxare provided, the property-based API, and the static functions. Calling one of the static functions is the simpler approach, but it is less flexible than using the property-based API, and the result is less informative. Using the property-based API is recommended.The Property-based API¶
To use the property-based API, construct an instance of
QMessageBox, set the desired properties, and callexec()to show the message. The simplest configuration is to set only themessage textproperty.msgBox = QMessageBox() msgBox.setText("The document has been modified.") msgBox.exec()
The user must click the OK button to dismiss the message box. The rest of the GUI is blocked until the message box is dismissed.
A better approach than just alerting the user to an event is to also ask the user what to do about it.
Set the
standard buttonsproperty to the set of buttons you want as the set of user responses. The buttons are specified by combining values fromStandardButtonsusing the bitwise OR operator. The display order for the buttons is platform-dependent. For example, on Windows, Save is displayed to the left of Cancel, whereas on macOS, the order is reversed. Mark one of your standard buttons to be yourdefault button.The
informative textproperty can be used to add additional context to help the user choose the appropriate action.msgBox = QMessageBox() msgBox.setText("The document has been modified.") msgBox.setInformativeText("Do you want to save your changes?") msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.StandardButton.Cancel) msgBox.setDefaultButton(QMessageBox.Save) ret = msgBox.exec()
The
exec()slot returns theStandardButtonsvalue of the button that was clicked.if ret == QMessageBox.Save: # Save was clicked break elif ret == QMessageBox.Discard: # Don't Save was clicked break elif ret == QMessageBox.StandardButton.Cancel: # Cancel was clicked break else: # should never be reached break
To give the user more information to help them choose the appropriate, action, set the
detailed textproperty. Depending on the platform thedetailed text, may require the user to click a Show Details… button to be shown.
Clicking the Show Details… button displays the detailed text.
Rich Text and the Text Format Property¶
The
detailed textproperty is always interpreted as plain text. Themain textandinformative textproperties can be either plain text or rich text. These strings are interpreted according to the setting of thetext formatproperty. The default setting is auto-text.Note that for some plain text strings containing XML meta-characters, the auto-text rich text detection test may fail causing your plain text string to be interpreted incorrectly as rich text. In these rare cases, use Qt::convertFromPlainText() to convert your plain text string to a visually equivalent rich text string, or set the
text formatproperty explicitly withsetTextFormat().Severity Levels and the Icon and Pixmap Properties¶
QMessageBoxsupports four predefined message severity levels, or message types, which really only differ in the predefined icon they each show. Specify one of the four predefined message types by setting theiconproperty to one of thepredefined icons. The following rules are guidelines:
For asking a question during normal operations.
For reporting information about normal operations.
For reporting non-critical errors.
For reporting critical errors.
Predefined iconsare not defined byQMessageBox, but provided by the style. The default value isNo Icon. The message boxes are otherwise the same for all cases. When using a standard icon, use the one recommended in the table, or use the one recommended by the style guidelines for your platform. If none of the standard icons is right for your message box, you can use a custom icon by setting theicon pixmapproperty instead of setting theiconproperty.In summary, to set an icon, use either
setIcon()for one of the standard icons, orsetIconPixmap()for a custom icon.The Static Functions API¶
Building message boxes with the static functions API, although convenient, is less flexible than using the property-based API, because the static function signatures lack parameters for setting the
informative textanddetailed textproperties. One work-around for this has been to use thetitleparameter as the message box main text and thetextparameter as the message box informative text. Because this has the obvious drawback of making a less readable message box, platform guidelines do not recommend it. The Microsoft Windows User Interface Guidelines recommend using the application name as thewindow's title, which means that if you have an informative text in addition to your main text, you must concatenate it to thetextparameter.Note that the static function signatures have changed with respect to their button parameters, which are now used to set the
standard buttonsand thedefault button.Static functions are available for creating
information(),question(),warning(), andcritical()message boxes.ret = QMessageBox.warning(self, tr("My Application"),() tr("The document has been modified.\n" "Do you want to save your changes?"), QMessageBox.Save | QMessageBox.Discard | QMessageBox.StandardButton.Cancel, QMessageBox.Save)
The Standard Dialogs example shows how to use
QMessageBoxand the other built-in Qt dialogs.Advanced Usage¶
If the
standard buttonsare not flexible enough for your message box, you can use theaddButton()overload that takes a text and aButtonRoleto add custom buttons. TheButtonRoleis used byQMessageBoxto determine the ordering of the buttons on screen (which varies according to the platform). You can test the value ofclickedButton()after callingexec(). For example,msgBox = QMessageBox() connectButton = msgBox.addButton(tr("Connect"), QMessageBox.ActionRole) abortButton = msgBox.addButton(QMessageBox.Abort) msgBox.exec() if msgBox.clickedButton() == connectButton: # connect elif msgBox.clickedButton() == abortButton: # abort
Default and Escape Keys¶
The default button (i.e., the button activated when Enter is pressed) can be specified using
setDefaultButton(). If a default button is not specified,QMessageBoxtries to find one based on thebutton rolesof the buttons used in the message box.The escape button (the button activated when Esc is pressed) can be specified using
setEscapeButton(). If an escape button is not specified,QMessageBoxtries to find one using these rules:If there is only one button, it is the button activated when Esc is pressed.
If there is a
Cancelbutton, it is the button activated when Esc is pressed.If there is exactly one button having either
the Reject roleor thethe No role, it is the button activated when Esc is pressed.
When an escape button can’t be determined using these rules, pressing Esc has no effect.
See also
QDialogButtonBoxStandard Dialogs Example- class Option¶
Constant
Description
QMessageBox.Option.Option.DontUseNativeDialog
(inherits
enum.Flag) Don’t use the native message dialog.Added in version 6.6.
- class Icon¶
This enum has the following values:
Constant
Description
QMessageBox.Icon.NoIcon
the message box does not have any icon.
QMessageBox.Icon.Question
an icon indicating that the message is asking a question.
QMessageBox.Icon.Information
an icon indicating that the message is nothing out of the ordinary.
QMessageBox.Icon.Warning
an icon indicating that the message is a warning, but can be dealt with.
QMessageBox.Icon.Critical
an icon indicating that the message represents a critical problem.
- class ButtonRole¶
This enum describes the roles that can be used to describe buttons in the button box. Combinations of these roles are as flags used to describe different aspects of their behavior.
Constant
Description
QMessageBox.ButtonRole.InvalidRole
The button is invalid.
QMessageBox.ButtonRole.AcceptRole
Clicking the button causes the dialog to be accepted (e.g. OK).
QMessageBox.ButtonRole.RejectRole
Clicking the button causes the dialog to be rejected (e.g. Cancel).
QMessageBox.ButtonRole.DestructiveRole
Clicking the button causes a destructive change (e.g. for Discarding Changes) and closes the dialog.
QMessageBox.ButtonRole.ActionRole
Clicking the button causes changes to the elements within the dialog.
QMessageBox.ButtonRole.HelpRole
The button can be clicked to request help.
QMessageBox.ButtonRole.YesRole
The button is a “Yes”-like button.
QMessageBox.ButtonRole.NoRole
The button is a “No”-like button.
QMessageBox.ButtonRole.ApplyRole
The button applies current changes.
QMessageBox.ButtonRole.ResetRole
The button resets the dialog’s fields to default values.
See also
- class StandardButton¶
(inherits
enum.IntFlag) These enums describe flags for standard buttons. Each button has a definedButtonRole.Constant
Description
QMessageBox.StandardButton.Ok
An “OK” button defined with the
AcceptRole.QMessageBox.StandardButton.Open
An “Open” button defined with the
AcceptRole.QMessageBox.StandardButton.Save
A “Save” button defined with the
AcceptRole.QMessageBox.StandardButton.Cancel
A “Cancel” button defined with the
RejectRole.QMessageBox.StandardButton.Close
A “Close” button defined with the
RejectRole.QMessageBox.StandardButton.Discard
A “Discard” or “Don’t Save” button, depending on the platform, defined with the
DestructiveRole.QMessageBox.StandardButton.Apply
An “Apply” button defined with the
ApplyRole.QMessageBox.StandardButton.Reset
A “Reset” button defined with the
ResetRole.QMessageBox.StandardButton.RestoreDefaults
A “Restore Defaults” button defined with the
ResetRole.QMessageBox.StandardButton.Help
A “Help” button defined with the
HelpRole.QMessageBox.StandardButton.SaveAll
A “Save All” button defined with the
AcceptRole.QMessageBox.StandardButton.Yes
A “Yes” button defined with the
YesRole.QMessageBox.StandardButton.YesToAll
A “Yes to All” button defined with the
YesRole.QMessageBox.StandardButton.No
A “No” button defined with the
NoRole.QMessageBox.StandardButton.NoToAll
A “No to All” button defined with the
NoRole.QMessageBox.StandardButton.Abort
An “Abort” button defined with the
RejectRole.QMessageBox.StandardButton.Retry
A “Retry” button defined with the
AcceptRole.QMessageBox.StandardButton.Ignore
An “Ignore” button defined with the
AcceptRole.QMessageBox.StandardButton.NoButton
An invalid button.
The following values are obsolete:
Constant
Description
QMessageBox.StandardButton.YesAll
Use YesToAll instead.
QMessageBox.StandardButton.NoAll
Use NoToAll instead.
QMessageBox.StandardButton.Default
Use the
defaultButtonargument ofinformation(),warning(), etc. instead, or callsetDefaultButton().QMessageBox.StandardButton.Escape
Call
setEscapeButton()instead.QMessageBox.StandardButton.FlagMask
QMessageBox.StandardButton.ButtonMask
See also
Note
Properties can be used directly when
from __feature__ import true_propertyis used or via accessor functions otherwise.- property detailedTextᅟ: str¶
This property holds the text to be displayed in the details area..
The text will be interpreted as a plain text.
By default, this property contains an empty string.
See also
- Access functions:
- property iconᅟ: QMessageBox.Icon¶
This property holds the message box’s icon.
The icon of the message box can be specified with one of the values:
The default is
NoIcon.The pixmap used to display the actual icon depends on the current
GUI style. You can also set a custom pixmap for the icon by setting theicon pixmapproperty.See also
This property holds the current icon.
The icon currently used by the message box. Note that it’s often hard to draw one pixmap that looks appropriate in all GUI styles; you may want to supply a different pixmap for each platform.
By default, this property is undefined.
See also
- Access functions:
- property informativeTextᅟ: str¶
This property holds the informative text that provides a fuller description for the message.
Informative text can be used to expand upon the
text()to give more information to the user, for example describing the consequences of the situation, or suggestion alternative solutions.The text will be interpreted either as a plain text or as rich text, depending on the text format setting (
textFormat). The default setting is Qt::AutoText, i.e., the message box will try to auto-detect the format of the text.By default, this property contains an empty string.
See also
- Access functions:
- property optionsᅟ: Combination of QAbstractFileIconProvider.Option¶
This property holds Options that affect the look and feel of the dialog..
By default, these options are disabled.
The option
DontUseNativeDialogshould be set before changing dialog properties or showing the dialog.Setting options while the dialog is visible is not guaranteed to have an immediate effect on the dialog.
Setting options after changing other properties may cause these values to have no effect.
See also
- Access functions:
- property standardButtonsᅟ: Combination of QDialogButtonBox.StandardButton¶
This property holds collection of standard buttons in the message box.
This property controls which standard buttons are used by the message box.
By default, this property contains no standard buttons.
See also
- Access functions:
- property textᅟ: str¶
This property holds the message box text to be displayed..
The text should be a brief sentence or phrase that describes the situation, ideally formulated as a neutral statement, or a call-to-action question.
The text will be interpreted either as a plain text or as rich text, depending on the text format setting (
textFormat). The default setting is Qt::AutoText, i.e., the message box will try to auto-detect the format of the text.The default value of this property is an empty string.
See also
- property textFormatᅟ: Qt.TextFormat¶
This property holds the format of the text displayed by the message box.
The current text format used by the message box. See the Qt::TextFormat enum for an explanation of the possible options.
The default format is Qt::AutoText.
See also
- Access functions:
- property textInteractionFlagsᅟ: Combination of Qt.TextInteractionFlag¶
Specifies how the label of the message box should interact with user input.
The default value depends on the style.
See also
- Access functions:
Constructs an application modal message box with no text and no buttons.
parentis passed to theQDialogconstructor.The window modality can be overridden via
setWindowModality()before callingshow().Note
Using
open()orexec()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
parent, set the message box’swindow modalityto Qt::WindowModal or useopen(). Otherwise, the message box will be a standard dialog.- __init__(icon, title, text[, buttons=QMessageBox.StandardButton.NoButton[, parent=None[, flags=Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint]]])
- Parameters:
icon –
Icontitle – str
text – str
buttons – Combination of
StandardButtonparent –
QWidgetflags – Combination of
WindowType
Constructs an application modal message box with the given
icon,title,text, and standardbuttons. Standard or custom buttons can be added at any time usingaddButton(). Theparentandfarguments are passed to theQDialogconstructor.The window modality can be overridden via
setWindowModality()before callingshow().Note
Using
open()orexec()to show the message box affects the window modality. Please see the detailed documentation for each function for more information.On macOS, if
parentis notNoneand you want your message box to appear as a Qt::Sheet of that parent, set the message box’swindow modalityto Qt::WindowModal (default). Otherwise, the message box will be a standard dialog.Displays a simple about box with title
titleand texttext. The about box’s parent isparent.about() looks for a suitable icon in four locations:
It prefers
parent->icon()if that exists.If not, it tries the top-level widget containing
parent.If that fails, it tries the
PySide6.QtWidgets.QApplication.activeWindow()As a last resort it uses the Information icon.
The about box has a single button labelled “OK”.
On macOS, the about box is popped up as a modeless window; on other platforms, it is currently application modal.
See also
Displays a simple message box about Qt, with the given
titleand centered overparent(ifparentis notNone). The message includes the version number of Qt being used by the application.This is useful for inclusion in the Help menu of an application, as shown in the Menus example.
QApplicationprovides this functionality as a slot.On macOS, the aboutQt box is popped up as a modeless window; on other platforms, it is currently application modal.
See also
- addButton(button)¶
- Parameters:
button –
StandardButton- Return type:
Adds a standard
buttonto the message box if it is valid to do so, and returns the push button.See also
- addButton(button, role)
- Parameters:
button –
QAbstractButtonrole –
ButtonRole
Adds the given
buttonto the message box with the specifiedrole.See also
- addButton(text, role)
- Parameters:
text – str
role –
ButtonRole
- Return type:
Creates a button with the given
text, adds it to the message box for the specifiedrole, and returns it.- button(which)¶
- Parameters:
which –
StandardButton- Return type:
Returns a pointer corresponding to the standard button
which, orNoneif the standard button doesn’t exist in this message box.Note
Modifying the properties of the returned button may not be reflected in native implementations of the message dialog. To customize dialog buttons add a
custom buttonorbutton titleinstead, or set theDontUseNativeDialogoption.See also
- buttonClicked(button)¶
- Parameters:
button –
QAbstractButton
This signal is emitted whenever a button is clicked inside the
QMessageBox. The button that was clicked in returned inbutton.- buttonRole(button)¶
- Parameters:
button –
QAbstractButton- Return type:
Returns the button role for the specified
button. This function returnsInvalidRoleifbuttonisNoneor has not been added to the message box.See also
- buttonText(button)¶
- Parameters:
button – int
- Return type:
str
Note
This function is deprecated.
Returns the text of the message box button
button, or an empty string if the message box does not contain the button.Use
button()andtext()instead.See also
- buttons()¶
- Return type:
.list of QAbstractButton
Returns a list of all the buttons that have been added to the message box.
See also
Returns the checkbox shown on the dialog. This is
Noneif no checkbox is set.See also
- clickedButton()¶
- Return type:
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
Returns the button that was clicked by the user, or
Noneif the user hit the Esc key and noescape buttonwas set.If
exec()hasn’t been called yet, returns nullptr.Example:
messageBox = QMessageBox(self) disconnectButton = messageBox.addButton(tr("Disconnect"), QMessageBox.ActionRole) ... messageBox.exec() if messageBox.clickedButton() == disconnectButton: ...
See also
- static critical(parent, title, text[, buttons=QMessageBox.StandardButton.Ok[, defaultButton=QMessageBox.StandardButton.NoButton]])¶
- Parameters:
parent –
QWidgettitle – str
text – str
buttons – Combination of
StandardButtondefaultButton –
StandardButton
- Return type:
Opens a critical message box with the given
titleandtextin front of the specifiedparentwidget.The standard
buttonsare added to the message box.defaultButtonspecifies the button used when Enter is pressed.defaultButtonmust refer to a button that was given inbuttons. IfdefaultButtonisNoButton,QMessageBoxchooses a suitable default automatically.Returns the identity of the standard button that was clicked. If Esc was pressed instead, the
escape buttonis returned.The message box is an application modal dialog box.
Warning
Do not delete
parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of theQMessageBoxconstructors.See also
- static critical(parent, title, text, button0, button1)
- Parameters:
parent –
QWidgettitle – str
text – str
button0 –
StandardButtonbutton1 –
StandardButton
- Return type:
int
Opens a critical message box with the given
titleandtextin front of the specifiedparentwidget.The standard
buttonsare added to the message box.defaultButtonspecifies the button used when Enter is pressed.defaultButtonmust refer to a button that was given inbuttons. IfdefaultButtonisNoButton,QMessageBoxchooses a suitable default automatically.Returns the identity of the standard button that was clicked. If Esc was pressed instead, the
escape buttonis returned.The message box is an application modal dialog box.
Warning
Do not delete
parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of theQMessageBoxconstructors.See also
- defaultButton()¶
- Return type:
Returns the button that should be the message box’s
default button. Returns nullptr if no default button was set.See also
- detailedText()¶
- Return type:
str
See also
Getter of property
detailedTextᅟ.- escapeButton()¶
- Return type:
Returns the button that is activated when escape is pressed.
By default,
QMessageBoxattempts to automatically detect an escape button as follows:If there is only one button, it is made the escape button.
If there is a
Cancelbutton, it is made the escape button.On macOS only, if there is exactly one button with the role
RejectRole, it is made the escape button.
When an escape button could not be automatically detected, pressing Esc has no effect.
See also
Getter of property
iconᅟ.- iconPixmap()¶
- Return type:
See also
Getter of property
iconPixmapᅟ.- static information(parent, title, text[, buttons=QMessageBox.StandardButton.Ok[, defaultButton=QMessageBox.StandardButton.NoButton]])¶
- Parameters:
parent –
QWidgettitle – str
text – str
buttons – Combination of
StandardButtondefaultButton –
StandardButton
- Return type:
Opens an information message box with the given
titleandtextin front of the specifiedparentwidget.The standard
buttonsare added to the message box.defaultButtonspecifies the button used when Enter is pressed.defaultButtonmust refer to a button that was given inbuttons. IfdefaultButtonisNoButton,QMessageBoxchooses a suitable default automatically.Returns the identity of the standard button that was clicked. If Esc was pressed instead, the
escape buttonis returned.The message box is an application modal dialog box.
Warning
Do not delete
parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of theQMessageBoxconstructors.See also
- static information(parent, title, text, button0[, button1=QMessageBox.StandardButton.NoButton])
- Parameters:
parent –
QWidgettitle – str
text – str
button0 –
StandardButtonbutton1 –
StandardButton
- Return type:
Opens an information message box with the given
titleandtextin front of the specifiedparentwidget.The standard
buttonsare added to the message box.defaultButtonspecifies the button used when Enter is pressed.defaultButtonmust refer to a button that was given inbuttons. IfdefaultButtonisNoButton,QMessageBoxchooses a suitable default automatically.Returns the identity of the standard button that was clicked. If Esc was pressed instead, the
escape buttonis returned.The message box is an application modal dialog box.
Warning
Do not delete
parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of theQMessageBoxconstructors.See also
- informativeText()¶
- Return type:
str
See also
Getter of property
informativeTextᅟ.- open(functor)¶
- Parameters:
functor –
PyCallable
- open(receiver, member)
- Parameters:
receiver –
QObjectmember – str
Opens the dialog and connects its
finished()orbuttonClicked()signal to the slot specified byreceiverandmember. If the slot inmemberhas a pointer for its first parameter the connection is tobuttonClicked(), otherwise the connection is tofinished().The signal will be disconnected from the slot when the dialog is closed.
- static question(parent, title, text[, buttons=QMessageBox.StandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)[, defaultButton=QMessageBox.StandardButton.NoButton]])¶
- Parameters:
parent –
QWidgettitle – str
text – str
buttons – Combination of
StandardButtondefaultButton –
StandardButton
- Return type:
Opens a question message box with the given
titleandtextin front of the specifiedparentwidget.The standard
buttonsare added to the message box.defaultButtonspecifies the button used when Enter is pressed.defaultButtonmust refer to a button that was given inbuttons. IfdefaultButtonisNoButton,QMessageBoxchooses a suitable default automatically.Returns the identity of the standard button that was clicked. If Esc was pressed instead, the
escape buttonis returned.The message box is an application modal dialog box.
Warning
Do not delete
parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of theQMessageBoxconstructors.See also
- static question(parent, title, text, button0, button1)
- Parameters:
parent –
QWidgettitle – str
text – str
button0 –
StandardButtonbutton1 –
StandardButton
- Return type:
int
Opens a question message box with the given
titleandtextin front of the specifiedparentwidget.The standard
buttonsare added to the message box.defaultButtonspecifies the button used when Enter is pressed.defaultButtonmust refer to a button that was given inbuttons. IfdefaultButtonisNoButton,QMessageBoxchooses a suitable default automatically.Returns the identity of the standard button that was clicked. If Esc was pressed instead, the
escape buttonis returned.The message box is an application modal dialog box.
Warning
Do not delete
parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of theQMessageBoxconstructors.See also
- removeButton(button)¶
- Parameters:
button –
QAbstractButton
Removes
buttonfrom the button box without deleting it.See also
- setButtonText(button, text)¶
- Parameters:
button – int
text – str
Note
This function is deprecated.
Sets the text of the message box button
buttontotext. Setting the text of a button that is not in the message box is silently ignored.Use
addButton()instead.See also
Sets the checkbox
cbon the message dialog. The message box takes ownership of the checkbox. The argumentcbcan beNoneto remove an existing checkbox from the message box.See also
- setDefaultButton(button)¶
- Parameters:
button –
StandardButton
Sets the message box’s
default buttontobutton.See also
- setDefaultButton(button)
- Parameters:
button –
QPushButton
Sets the message box’s
default buttontobutton.See also
- setDetailedText(text)¶
- Parameters:
text – str
See also
Setter of property
detailedTextᅟ.- setEscapeButton(button)¶
- Parameters:
button –
QAbstractButton
Sets the button that gets activated when the Escape key is pressed to
button.See also
- setEscapeButton(button)
- Parameters:
button –
StandardButton
Sets the buttons that gets activated when the Escape key is pressed to
button.See also
Setter of property
iconᅟ.Setter of property
iconPixmapᅟ.- setInformativeText(text)¶
- Parameters:
text – str
See also
Setter of property
informativeTextᅟ.Sets the given
optionto be enabled ifonis true; otherwise, clears the givenoption.Options (particularly the
DontUseNativeDialogoption) should be set before showing the dialog.Setting options while the dialog is visible is not guaranteed to have an immediate effect on the dialog.
Setting options after changing other properties may cause these values to have no effect.
See also
- setStandardButtons(buttons)¶
- Parameters:
buttons – Combination of
StandardButton
See also
Setter of property
textᅟ.- setTextFormat(format)¶
- Parameters:
format –
TextFormat
See also
Setter of property
textFormatᅟ.- setTextInteractionFlags(flags)¶
- Parameters:
flags – Combination of
TextInteractionFlag
See also
Setter of property
textInteractionFlagsᅟ.- setWindowModality(windowModality)¶
- Parameters:
windowModality –
WindowModality
This function shadows
setWindowModality().Sets the modality of the message box to
windowModality.On macOS, if the modality is set to Qt::WindowModal and the message box has a parent, then the message box will be a Qt::Sheet, otherwise the message box will be a standard dialog.
- setWindowTitle(title)¶
- Parameters:
title – str
This function shadows
setWindowTitle().Sets the title of the message box to
title. On macOS, the window title is ignored (as required by the macOS Guidelines).- standardButton(button)¶
- Parameters:
button –
QAbstractButton- Return type:
Returns the standard button enum value corresponding to the given
button, orNoButtonif the givenbuttonisn’t a standard button.See also
- standardButtons()¶
- Return type:
Combination of
StandardButton
See also
- static standardIcon(icon)¶
-
Note
This function is deprecated.
Returns the pixmap used for a standard icon. This allows the pixmaps to be used in more complex message boxes.
iconspecifies the required icon, e.g.Question,Information,WarningorCritical.Call
standardIcon()withSP_MessageBoxInformationetc. instead.Returns
trueif the givenoptionis enabled; otherwise, returns false.See also
Getter of property
textᅟ.- textFormat()¶
- Return type:
See also
Getter of property
textFormatᅟ.- textInteractionFlags()¶
- Return type:
Combination of
TextInteractionFlag
See also
Getter of property
textInteractionFlagsᅟ.- static warning(parent, title, text[, buttons=QMessageBox.StandardButton.Ok[, defaultButton=QMessageBox.StandardButton.NoButton]])¶
- Parameters:
parent –
QWidgettitle – str
text – str
buttons – Combination of
StandardButtondefaultButton –
StandardButton
- Return type:
Opens a warning message box with the given
titleandtextin front of the specifiedparentwidget.The standard
buttonsare added to the message box.defaultButtonspecifies the button used when Enter is pressed.defaultButtonmust refer to a button that was given inbuttons. IfdefaultButtonisNoButton,QMessageBoxchooses a suitable default automatically.Returns the identity of the standard button that was clicked. If Esc was pressed instead, the
escape buttonis returned.The message box is an application modal dialog box.
Warning
Do not delete
parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of theQMessageBoxconstructors.See also
- static warning(parent, title, text, button0, button1)
- Parameters:
parent –
QWidgettitle – str
text – str
button0 –
StandardButtonbutton1 –
StandardButton
- Return type:
int
Opens a warning message box with the given
titleandtextin front of the specifiedparentwidget.The standard
buttonsare added to the message box.defaultButtonspecifies the button used when Enter is pressed.defaultButtonmust refer to a button that was given inbuttons. IfdefaultButtonisNoButton,QMessageBoxchooses a suitable default automatically.Returns the identity of the standard button that was clicked. If Esc was pressed instead, the
escape buttonis returned.The message box is an application modal dialog box.
Warning
Do not delete
parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of theQMessageBoxconstructors.See also