CopperSpice API
1.9.2
|
The QMessageBox class provides a modal dialog for informing the user or for asking the user a question and receiving an answer. More...
Public Typedefs | |
using | StandardButtons = QFlags< StandardButton > |
Public Typedefs inherited from QWidget | |
using | RenderFlags = QFlags< RenderFlag > |
Public Types | |
enum | ButtonRole |
enum | Icon |
enum | StandardButton |
Public Types inherited from QDialog | |
enum | DialogCode |
Public Types inherited from QWidget | |
enum | RenderFlag |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric |
Public Signals | |
void | buttonClicked (QAbstractButton *button) |
Public Signals inherited from QDialog | |
void | accepted () |
void | finished (int result) |
void | rejected () |
Public Signals inherited from QWidget | |
void | customContextMenuRequested (const QPoint &pos) |
void | windowIconChanged (const QIcon &icon) |
void | windowIconTextChanged (const QString &iconText) |
void | windowTitleChanged (const QString &title) |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots | |
virtual void | open () |
Public Slots inherited from QDialog | |
virtual void | accept () |
virtual void | done (int result) |
virtual int | exec () |
virtual void | open () |
virtual void | reject () |
void | showExtension (bool showExt) |
Public Slots inherited from QWidget | |
bool | close () |
void | hide () |
void | lower () |
void | raise () |
void | repaint () |
void | setDisabled (bool disable) |
void | setEnabled (bool enable) |
void | setFocus () |
void | setHidden (bool hidden) |
void | setStyleSheet (const QString &styleSheet) |
virtual void | setVisible (bool visible) |
void | setWindowModified (bool modified) |
void | setWindowTitle (const QString &title) |
void | show () |
void | showFullScreen () |
void | showMaximized () |
void | showMinimized () |
void | showNormal () |
void | update () |
Public Slots inherited from QObject | |
void | deleteLater () |
Public Methods | |
QMessageBox (const QString &title, const QString &text, Icon icon, int button0, int button1, int button2, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint) | |
QMessageBox (Icon icon, const QString &title, const QString &text, StandardButtons buttons=NoButton, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint) | |
QMessageBox (QWidget *parent=nullptr) | |
~QMessageBox () | |
QPushButton * | addButton (const QString &text, ButtonRole role) |
void | addButton (QAbstractButton *button, ButtonRole role) |
QPushButton * | addButton (StandardButton button) |
QAbstractButton * | button (StandardButton which) const |
ButtonRole | buttonRole (QAbstractButton *button) const |
QList< QAbstractButton * > | buttons () const |
QString | buttonText (int button) const |
QCheckBox * | checkBox () const |
QAbstractButton * | clickedButton () const |
QPushButton * | defaultButton () const |
QString | detailedText () const |
QAbstractButton * | escapeButton () const |
int | exec () |
Icon | icon () const |
QPixmap | iconPixmap () const |
QString | informativeText () const |
void | open (QObject *receiver, const QString &member) |
void | removeButton (QAbstractButton *button) |
void | setButtonText (int button, const QString &text) |
void | setCheckBox (QCheckBox *cb) |
void | setDefaultButton (QPushButton *button) |
void | setDefaultButton (StandardButton button) |
void | setDetailedText (const QString &text) |
void | setEscapeButton (QAbstractButton *button) |
void | setEscapeButton (StandardButton button) |
void | setIcon (QMessageBox::Icon icon) |
void | setIconPixmap (const QPixmap &pixmap) |
void | setInformativeText (const QString &text) |
void | setStandardButtons (StandardButtons buttons) |
void | setText (const QString &text) |
void | setTextFormat (Qt::TextFormat format) |
void | setTextInteractionFlags (Qt::TextInteractionFlags flags) |
void | setWindowModality (Qt::WindowModality windowModality) |
void | setWindowTitle (const QString &title) |
StandardButton | standardButton (QAbstractButton *button) const |
StandardButtons | standardButtons () const |
QString | text () const |
Qt::TextFormat | textFormat () const |
Qt::TextInteractionFlags | textInteractionFlags () const |
Public Methods inherited from QDialog | |
QDialog (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) | |
~QDialog () | |
QWidget * | extension () const |
bool | isSizeGripEnabled () const |
QSize | minimumSizeHint () const override |
Qt::Orientation | orientation () const |
int | result () const |
void | setExtension (QWidget *extension) |
void | setModal (bool modal) |
void | setOrientation (Qt::Orientation orientation) |
void | setResult (int result) |
void | setSizeGripEnabled (bool enabled) |
void | setVisible (bool visible) override |
QSize | sizeHint () const override |
Public Methods inherited from QWidget | |
QWidget (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) | |
~QWidget () | |
bool | acceptDrops () const |
QString | accessibleDescription () const |
QString | accessibleName () const |
QList< QAction * > | actions () const |
void | activateWindow () |
void | addAction (QAction *action) |
void | addActions (const QList< QAction * > &actions) |
void | adjustSize () |
bool | autoFillBackground () const |
QPalette::ColorRole | backgroundRole () const |
QBackingStore * | backingStore () const |
QSize | baseSize () const |
QWidget * | childAt (const QPoint &position) const |
QWidget * | childAt (int x, int y) const |
QRect | childrenRect () const |
QRegion | childrenRegion () const |
void | clearFocus () |
void | clearMask () |
QMargins | contentsMargins () const |
QRect | contentsRect () const |
Qt::ContextMenuPolicy | contextMenuPolicy () const |
QCursor | cursor () const |
WId | effectiveWinId () const |
void | ensurePolished () const |
Qt::FocusPolicy | focusPolicy () const |
QWidget * | focusProxy () const |
QWidget * | focusWidget () const |
const QFont & | font () const |
QFontInfo | fontInfo () const |
QFontMetrics | fontMetrics () const |
QPalette::ColorRole | foregroundRole () const |
QRect | frameGeometry () const |
QSize | frameSize () const |
const QRect & | geometry () const |
void | getContentsMargins (int *left, int *top, int *right, int *bottom) const |
QPixmap | grab (const QRect &rectangle=QRect (QPoint (0, 0), QSize (-1,-1))) |
void | grabGesture (Qt::GestureType gestureType, Qt::GestureFlags flags=Qt::GestureFlags ()) |
void | grabKeyboard () |
void | grabMouse () |
void | grabMouse (const QCursor &cursor) |
int | grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut) |
QGraphicsEffect * | graphicsEffect () const |
QGraphicsProxyWidget * | graphicsProxyWidget () const |
bool | hasEditFocus () const |
bool | hasFocus () const |
virtual bool | hasHeightForWidth () const |
bool | hasMouseTracking () const |
int | height () const |
virtual int | heightForWidth (int width) const |
Qt::InputMethodHints | inputMethodHints () const |
virtual QVariant | inputMethodQuery (Qt::InputMethodQuery query) const |
void | insertAction (QAction *before, QAction *action) |
void | insertActions (QAction *before, QList< QAction * > actions) |
bool | isActiveWindow () const |
bool | isAncestorOf (const QWidget *child) const |
bool | isEnabled () const |
bool | isEnabledTo (const QWidget *parent) const |
bool | isEnabledToTLW () const |
bool | isFullScreen () const |
bool | isHidden () const |
bool | isMaximized () const |
bool | isMinimized () const |
bool | isModal () const |
bool | isTopLevel () const |
bool | isVisible () const |
bool | isVisibleTo (const QWidget *parent) const |
bool | isWindow () const |
bool | isWindowModified () const |
QLayout * | layout () const |
Qt::LayoutDirection | layoutDirection () const |
QLocale | locale () const |
QPoint | mapFrom (const QWidget *parent, const QPoint &pos) const |
QPoint | mapFromGlobal (const QPoint &pos) const |
QPoint | mapFromParent (const QPoint &pos) const |
QPoint | mapTo (const QWidget *parent, const QPoint &pos) const |
QPoint | mapToGlobal (const QPoint &pos) const |
QPoint | mapToParent (const QPoint &pos) const |
QRegion | mask () const |
int | maximumHeight () const |
QSize | maximumSize () const |
int | maximumWidth () const |
int | minimumHeight () const |
QSize | minimumSize () const |
int | minimumWidth () const |
void | move (const QPoint &point) |
void | move (int x, int y) |
QWidget * | nativeParentWidget () const |
QWidget * | nextInFocusChain () const |
QRect | normalGeometry () const |
void | overrideWindowFlags (Qt::WindowFlags flags) |
QPaintEngine * | paintEngine () const override |
const QPalette & | palette () const |
QWidget * | parentWidget () const |
QPoint | pos () const |
QWidget * | previousInFocusChain () const |
QRect | rect () const |
void | releaseKeyboard () |
void | releaseMouse () |
void | releaseShortcut (int id) |
void | removeAction (QAction *action) |
void | render (QPaintDevice *target, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren)) |
void | render (QPainter *painter, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren)) |
void | repaint (const QRect &rect) |
void | repaint (const QRegion ®ion) |
void | repaint (int x, int y, int w, int h) |
void | resize (const QSize &size) |
void | resize (int w, int h) |
bool | restoreGeometry (const QByteArray &geometry) |
QByteArray | saveGeometry () const |
void | scroll (int dx, int dy) |
void | scroll (int dx, int dy, const QRect &rect) |
void | setAcceptDrops (bool on) |
void | setAccessibleDescription (const QString &description) |
void | setAccessibleName (const QString &name) |
void | setAttribute (Qt::WidgetAttribute attribute, bool enable=true) |
void | setAutoFillBackground (bool enable) |
void | setBackgroundRole (QPalette::ColorRole role) |
void | setBaseSize (const QSize &size) |
void | setBaseSize (int basew, int baseh) |
void | setContentsMargins (const QMargins &margins) |
void | setContentsMargins (int left, int top, int right, int bottom) |
void | setContextMenuPolicy (Qt::ContextMenuPolicy policy) |
void | setCursor (const QCursor &cursor) |
void | setEditFocus (bool enable) |
void | setFixedHeight (int h) |
void | setFixedSize (const QSize &size) |
void | setFixedSize (int w, int h) |
void | setFixedWidth (int w) |
void | setFocus (Qt::FocusReason reason) |
void | setFocusPolicy (Qt::FocusPolicy policy) |
void | setFocusProxy (QWidget *widget) |
void | setFont (const QFont &font) |
void | setForegroundRole (QPalette::ColorRole role) |
void | setGeometry (const QRect &rect) |
void | setGeometry (int x, int y, int w, int h) |
void | setGraphicsEffect (QGraphicsEffect *effect) |
void | setInputMethodHints (Qt::InputMethodHints hints) |
void | setLayout (QLayout *layout) |
void | setLayoutDirection (Qt::LayoutDirection direction) |
void | setLocale (const QLocale &locale) |
void | setMask (const QBitmap &bitmap) |
void | setMask (const QRegion ®ion) |
void | setMaximumHeight (int maxh) |
void | setMaximumSize (const QSize &size) |
void | setMaximumSize (int maxw, int maxh) |
void | setMaximumWidth (int maxw) |
void | setMinimumHeight (int minh) |
void | setMinimumSize (const QSize &size) |
void | setMinimumSize (int minw, int minh) |
void | setMinimumWidth (int minw) |
void | setMouseTracking (bool enable) |
void | setPalette (const QPalette &palette) |
void | setParent (QWidget *parent) |
void | setParent (QWidget *parent, Qt::WindowFlags flags) |
void | setShortcutAutoRepeat (int id, bool enable=true) |
void | setShortcutEnabled (int id, bool enable=true) |
void | setSizeIncrement (const QSize &size) |
void | setSizeIncrement (int w, int h) |
void | setSizePolicy (QSizePolicy policy) |
void | setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) |
void | setStatusTip (const QString &data) |
void | setStyle (QStyle *style) |
void | setToolTip (const QString &data) |
void | setToolTipDuration (int msec) |
void | setUpdatesEnabled (bool enable) |
void | setWhatsThis (const QString &str) |
void | setWindowFilePath (const QString &filePath) |
void | setWindowFlags (Qt::WindowFlags flags) |
void | setWindowIcon (const QIcon &icon) |
void | setWindowModality (Qt::WindowModality windowModality) |
void | setWindowOpacity (qreal level) |
void | setWindowRole (const QString &role) |
void | setWindowState (Qt::WindowStates windowState) |
QSize | size () const |
QSize | sizeIncrement () const |
QSizePolicy | sizePolicy () const |
void | stackUnder (QWidget *widget) |
QString | statusTip () const |
QStyle * | style () const |
QString | styleSheet () const |
bool | testAttribute (Qt::WidgetAttribute attribute) const |
QString | toolTip () const |
int | toolTipDuration () const |
QWidget * | topLevelWidget () const |
bool | underMouse () const |
void | ungrabGesture (Qt::GestureType gestureType) |
void | unsetCursor () |
void | unsetLayoutDirection () |
void | unsetLocale () |
void | update (const QRect &rect) |
void | update (const QRegion ®ion) |
void | update (int x, int y, int w, int h) |
void | updateGeometry () |
bool | updatesEnabled () const |
QRegion | visibleRegion () const |
QString | whatsThis () const |
int | width () const |
QWidget * | window () const |
QString | windowFilePath () const |
Qt::WindowFlags | windowFlags () const |
QWindow * | windowHandle () const |
QIcon | windowIcon () const |
Qt::WindowModality | windowModality () const |
qreal | windowOpacity () const |
QString | windowRole () const |
Qt::WindowStates | windowState () const |
QString | windowTitle () const |
Qt::WindowType | windowType () const |
WId | winId () const |
int | x () const |
int | y () const |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Public Methods inherited from QPaintDevice | |
virtual | ~QPaintDevice () |
int | colorCount () const |
int | depth () const |
int | devicePixelRatio () const |
qreal | devicePixelRatioF () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
int | width () const |
int | widthMM () const |
Static Public Methods | |
static void | about (QWidget *parent, const QString &title, const QString &text) |
static void | aboutCs (QWidget *parent, const QString &title=QString ()) |
static int | critical (QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text=QString (), const QString &button2Text=QString (), int defaultButtonNumber=0, int escapeButtonNumber=-1) |
static int | critical (QWidget *parent, const QString &title, const QString &text, int button0, int button1, int button2=0) |
static StandardButton | critical (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
static int | information (QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text=QString (), const QString &button2Text=QString (), int defaultButtonNumber=0, int escapeButtonNumber=-1) |
static int | information (QWidget *parent, const QString &title, const QString &text, int button0, int button1=0, int button2=0) |
static StandardButton | information (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
static int | question (QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text=QString (), const QString &button2Text=QString (), int defaultButtonNumber=0, int escapeButtonNumber=-1) |
static int | question (QWidget *parent, const QString &title, const QString &text, int button0, int button1=0, int button2=0) |
static StandardButton | question (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=StandardButtons (Yes|No), StandardButton defaultButton=NoButton) |
static QPixmap | standardIcon (Icon icon) |
static int | warning (QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text=QString (), const QString &button2Text=QString (), int defaultButtonNumber=0, int escapeButtonNumber=-1) |
static int | warning (QWidget *parent, const QString &title, const QString &text, int button0, int button1, int button2=0) |
static StandardButton | warning (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
Static Public Methods inherited from QWidget | |
static QWidget * | createWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) |
static QWidget * | find (WId id) |
static QWidget * | keyboardGrabber () |
static QWidget * | mouseGrabber () |
static void | setTabOrder (QWidget *firstWidget, QWidget *secondWidget) |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Protected Methods | |
void | changeEvent (QEvent *event) override |
void | closeEvent (QCloseEvent *event) override |
bool | event (QEvent *event) override |
void | keyPressEvent (QKeyEvent *event) override |
void | resizeEvent (QResizeEvent *event) override |
void | showEvent (QShowEvent *event) override |
Protected Methods inherited from QDialog | |
void | contextMenuEvent (QContextMenuEvent *event) override |
bool | eventFilter (QObject *object, QEvent *event) override |
Protected Methods inherited from QWidget | |
virtual void | actionEvent (QActionEvent *event) |
void | create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true) |
void | destroy (bool destroyWindow=true, bool destroySubWindows=true) |
virtual void | dragEnterEvent (QDragEnterEvent *event) |
virtual void | dragLeaveEvent (QDragLeaveEvent *event) |
virtual void | dragMoveEvent (QDragMoveEvent *event) |
virtual void | dropEvent (QDropEvent *event) |
virtual void | enterEvent (QEvent *event) |
bool | event (QEvent *event) override |
virtual void | focusInEvent (QFocusEvent *event) |
bool | focusNextChild () |
virtual bool | focusNextPrevChild (bool next) |
virtual void | focusOutEvent (QFocusEvent *event) |
bool | focusPreviousChild () |
virtual void | hideEvent (QHideEvent *event) |
void | initPainter (QPainter *painter) const override |
virtual void | inputMethodEvent (QInputMethodEvent *event) |
virtual void | keyReleaseEvent (QKeyEvent *event) |
virtual void | leaveEvent (QEvent *event) |
int | metric (PaintDeviceMetric metric) const override |
virtual void | mouseDoubleClickEvent (QMouseEvent *event) |
virtual void | mouseMoveEvent (QMouseEvent *event) |
virtual void | mousePressEvent (QMouseEvent *event) |
virtual void | mouseReleaseEvent (QMouseEvent *event) |
virtual void | moveEvent (QMoveEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, long *result) |
virtual void | paintEvent (QPaintEvent *event) |
virtual void | tabletEvent (QTabletEvent *event) |
virtual void | wheelEvent (QWheelEvent *event) |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Methods inherited from QPaintDevice | |
QPaintDevice () | |
Additional Inherited Members | |
Protected Slots inherited from QWidget | |
void | updateMicroFocus () |
Related Functions inherited from QWidget | |
QWidgetList | |
WId | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QMessageBox class provides a modal dialog for informing the user or for asking the user a question and receiving an answer. A message box displays a primary text to alert the user to a situation, an informative text to further explain the alert or to ask the user a question, and an optional detailed text to provide even more data if the user requests it. A message box can also display an icon and standard buttons for accepting a user response.
You can use QMessageBox in two different ways, by calling a static method or creating an instance. Calling one of the static methods is simpler but it is less flexible than using an instance. Using the instance API is recommended.
To use this approach construct an instance of QMessageBox and set the desired properties. Then call exec() to show the message. The simplest configuration is to set only the message text property.
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 is to ask the user what they want to do. You should display the question by setting the informative text property and use the standard buttons property to display only relevant buttons. The buttons are specified by combining values from StandardButtons using the bitwise OR operator. The display order for the buttons is platform dependent.
On Windows Save is displayed to the left of Cancel, whereas on Mac OS X the order is reversed. It is advisable to mark one of your standard buttons as the default.
This is the approach recommended in the OS X Guidelines. Similar guidelines apply for the other platforms, but note the different ways the informative text is handled for different platforms.
The exec() slot returns the StandardButtons value of the button that was clicked.
The first example adds an additional button which the user can press for detailed information. The second example shows the detailed information in the same window.
The detailed text property is always interpreted as plain text. The main text and informative text properties can be either plain text or rich text. These strings are interpreted according to the setting of the text format property. 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 format property explicitly with setTextFormat().
QMessageBox supports 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 the icon property to one of the predefined icons. The following rules are guidelines:
Question | For asking a question during normal operations. | |
Information | For reporting information about normal operations. | |
Warning | For reporting non-critical errors. | |
Critical | For reporting critical errors. |
Predefined icons are not defined by QMessageBox, but provided by the style. The default value is No 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 the icon pixmap property instead of setting the icon property.
In summary, to set an icon, use either setIcon() for one of the standard icons, or setIconPixmap() for a custom icon.
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 text and detailed text properties. One work-around for this has been to use the title
parameter as the message box main text and the text
parameter 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 the window's title, which means that if you have an informative text in addition to your main text, you must concatenate it to the text
parameter.
Note that the static function signatures have changed with respect to their button parameters, which are now used to set the standard buttons and the default button.
Static functions are available for creating information(), question(), warning(), and critical() message boxes.
If the standard buttons are not flexible enough for your message box, you can use the addButton() overload that takes a text and a ButtonRole to add custom buttons. The ButtonRole is used by QMessageBox to determine the ordering of the buttons on screen (which varies according to the platform). You can test the value of clickedButton() after calling exec().
The default button (i.e., the button activated when Enter is pressed) can be specified using setDefaultButton(). If a default button is not specified, QMessageBox tries to find one based on the button roles of 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, QMessageBox tries to find one using these rules:
When an escape button can not be determined using these rules, pressing Esc has no effect.
Typedef for QFlags<QMessageBox::StandardButton> which contains an OR combination of StandardButton values.
Refer to QMessageBox::StandardButton for the enum documentation.
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 | Value | Description |
---|---|---|
QMessageBox::InvalidRole | -1 | The button is invalid. |
QMessageBox::AcceptRole | 0 | Clicking the button causes the dialog to be accepted (e.g. OK). |
QMessageBox::RejectRole | 1 | Clicking the button causes the dialog to be rejected (e.g. Cancel). |
QMessageBox::DestructiveRole | 2 | Clicking the button causes a destructive change (e.g. for Discarding Changes) and closes the dialog. |
QMessageBox::ActionRole | 3 | Clicking the button causes changes to the elements within the dialog. |
QMessageBox::HelpRole | 4 | The button can be clicked to request help. |
QMessageBox::YesRole | 5 | The button is a "Yes"-like button. |
QMessageBox::NoRole | 6 | The button is a "No"-like button. |
QMessageBox::ResetRole | 7 | The button resets the dialog's fields to default values. |
QMessageBox::ApplyRole | 8 | The button applies current changes. |
enum QMessageBox::Icon |
This enum has the following values:
Constant | Value | Description |
---|---|---|
QMessageBox::NoIcon | 0 | Message box does not have any icon. |
QMessageBox::Information | 1 | Icon indicates the message is nothing out of the ordinary. |
QMessageBox::Warning | 2 | Icon indicates the message is a warning, but can be dealt with. |
QMessageBox::Critical | 3 | Icon indicates the message represents a critical problem. |
QMessageBox::Question | 4 | Icon indicates the message is asking a question. |
These enums describe flags for standard buttons. Each button has a defined ButtonRole.
Constant | Value | Description |
---|---|---|
QMessageBox::NoButton | 0x00000000 | Invalid button. |
QMessageBox::Ok | 0x00000400 | "OK" button defined with the AcceptRole. |
QMessageBox::Save | 0x00000800 | "Save" button defined with the AcceptRole. |
QMessageBox::SaveAll | 0x00001000 | "Save All" button defined with the AcceptRole. |
QMessageBox::Open | 0x00002000 | "Open" button defined with the AcceptRole. |
QMessageBox::Yes | 0x00004000 | "Yes" button defined with the YesRole. |
QMessageBox::YesToAll | 0x00008000 | "Yes to All" button defined with the YesRole. |
QMessageBox::No | 0x00010000 | "No" button defined with the NoRole. |
QMessageBox::NoToAll | 0x00020000 | "No to All" button defined with the NoRole. |
QMessageBox::Abort | 0x00040000 | "Abort" button defined with the RejectRole. |
QMessageBox::Retry | 0x00080000 | "Retry" button defined with the AcceptRole. |
QMessageBox::Ignore | 0x00100000 | "Ignore" button defined with the AcceptRole. |
QMessageBox::Close | 0x00200000 | "Close" button defined with the RejectRole. |
QMessageBox::Cancel | 0x00400000 | "Cancel" button defined with the RejectRole. |
QMessageBox::Discard | 0x00800000 | "Discard" or "Do not Save" button, depending on the platform, defined with the DestructiveRole. |
QMessageBox::Help | 0x01000000 | "Help" button defined with the HelpRole. |
QMessageBox::Apply | 0x02000000 | "Apply" button defined with the ApplyRole. |
QMessageBox::Reset | 0x04000000 | "Reset" button defined with the ResetRole. |
QMessageBox::RestoreDefaults | 0x08000000 | "Restore Defaults" button defined with the ResetRole. |
The following enum values are obsolete.
Constant | Value | Description |
---|---|---|
QMessageBox::YesAll | YesToAll | Use YesToAll instead. |
QMessageBox::NoAll | NoToAll | Use NoToAll instead. |
QMessageBox::Default | 0x00000100 | Use the defaultButton argument for information(), warning()or call setDefaultButton(). |
QMessageBox::Escape | 0x00000200 | Call setEscapeButton() instead. |
QMessageBox::FlagMask | 0x00000300 | |
QMessageBox::ButtonMask | ~FlagMask |
|
explicit |
Constructs a message box with no text and no buttons using the given parent.
On OS X to display a message box as a Qt::Sheet of the parent, set the message box window modality to Qt::WindowModal or use open(). Otherwise, the message box will be a standard dialog.
QMessageBox::QMessageBox | ( | Icon | icon, |
const QString & | title, | ||
const QString & | text, | ||
StandardButtons | buttons = NoButton , |
||
QWidget * | parent = nullptr , |
||
Qt::WindowFlags | flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint |
||
) |
Constructs a message box with the given icon, title, text, and standard buttons. Standard or custom buttons can be added at any time using addButton(). The parent and flags arguments are passed to the QDialog constructor. The message box is an application modal dialog box.
On Mac OS X if the given parent is not a nullptr and the message box should appear as a Qt::Sheet of this parent, set the message box window modality to Qt::WindowModal. Otherwise, the message box will be a standard dialog.
QMessageBox::~QMessageBox | ( | ) |
Destroys the message box.
|
deprecated |
Constructs a message box with title, text, icon, and up to three buttons.
Displays a simple about box with title and text. The about box's parent is parent. The about box has a single button labeled OK. On OS X the about box is displayed as a modeless window. On other platforms it is application modal.
This method looks for a suitable icon in four locations as listed below.
Displays a simple message box about CopperSpice, with the given title and centered over parent if is not a nullptr. The message includes the version number of CopperSpice being used by the application.
This message box is useful for inclusion in the Help menu of your application.
QApplication provides this functionality as a slot. On OS X the about box is displayed as a modeless window. On other platforms it is application modal.
QPushButton * QMessageBox::addButton | ( | const QString & | text, |
ButtonRole | role | ||
) |
Creates a button with the given text, adds it to the message box for the specified role, and returns a pointer to the new button.
void QMessageBox::addButton | ( | QAbstractButton * | button, |
ButtonRole | role | ||
) |
Adds the given button to the message box with the specified role.
QPushButton * QMessageBox::addButton | ( | StandardButton | button | ) |
Adds a standard button to the message box if it is valid to do so. Returns a pointer to the push button.
QAbstractButton * QMessageBox::button | ( | StandardButton | which | ) | const |
Returns a pointer corresponding to the standard button which or a nullptr if the standard button does not exist in this message box.
|
signal |
This signal is emitted whenever a button is clicked inside the QMessageBox. The button which was clicked is passed as the button argument.
ButtonRole QMessageBox::buttonRole | ( | QAbstractButton * | button | ) | const |
Returns the button role for the specified button. This method returns InvalidRole if button is a nullptr or has not been added to the message box.
QList< QAbstractButton * > QMessageBox::buttons | ( | ) | const |
Returns a list of all the buttons that have been added to the message box.
|
deprecated |
Returns the text of the message box button or an empty string if the message box does not contain the button.
|
overrideprotectedvirtual |
Reimplemented from QWidget::changeEvent()
QCheckBox * QMessageBox::checkBox | ( | ) | const |
Returns a pointer to the QCheckBox shown on the dialog. This is nullptr if no checkbox is set.
QAbstractButton * QMessageBox::clickedButton | ( | ) | const |
Returns the button that was clicked by the user or a nullptr if the user hit the Esc key and no escape button was set. If exec() has not been called yet returns nullptr.
|
overrideprotectedvirtual |
Reimplemented from QDialog::closeEvent()
|
deprecatedstatic |
Displays a critical error message box with the given title and text, as well as one, two, or three buttons. Returns the number of the button that was clicked (0, 1 or 2).
|
deprecatedstatic |
Opens a critical message box with the given title and text. The dialog may have up to three buttons.
|
static |
Opens a critical message box with the given title and text in front of the specified parent widget.
The standard buttons are added to the message box. The defaultButton specifies the button used when Enter is pressed and must refer to a button which was listed in buttons. If defaultButton is QMessageBox::NoButton, QMessageBox chooses a suitable default automatically.
Returns the identity of the standard button that was clicked. If Esc was pressed instead, the escape button is returned. The message box is an application modal dialog box.
QPushButton * QMessageBox::defaultButton | ( | ) | const |
Returns the button that should be the message box's default button. Returns a nullptr if no default button was set.
QString QMessageBox::detailedText | ( | ) | const |
Returns the value of the property.
QAbstractButton * QMessageBox::escapeButton | ( | ) | const |
Returns the button that is activated when escape is pressed. By default, QMessageBox attempts to automatically detect an escape button as follows.
When an escape button could not be automatically detected, pressing Esc has no effect.
|
overrideprotected |
Reimplemented from QWidget::event()
int QMessageBox::exec | ( | ) |
Shows the message box as a modal dialog, blocking until the user closes it. Users can not interact with any other window in the same application until they close the dialog, either by clicking a button or by using a mechanism provided by the window system.
When using a QMessageBox with standard buttons this functions returns a StandardButton value indicating the standard button which was clicked. When using QMessageBox with custom buttons this function returns an opaque value. Use clickedButton() to determine which button was clicked.
The result() function returns also StandardButton value instead of QDialog::DialogCode
Icon QMessageBox::icon | ( | ) | const |
Returns the value of the property.
QPixmap QMessageBox::iconPixmap | ( | ) | const |
Returns the value of the property.
|
deprecatedstatic |
|
deprecatedstatic |
Opens an information message box with the given title and the text. The dialog may have up to three buttons.
|
static |
Opens an information message box with the given title and text in front of the specified parent widget.
The standard buttons are added to the message box. The defaultButton specifies the button used when Enter is pressed and must refer to a button which was listed in buttons. If defaultButton is QMessageBox::NoButton, QMessageBox chooses a suitable default automatically.
Returns the identity of the standard button that was clicked. If Esc was pressed instead, the escape button is returned. The message box is an application modal dialog box.
QString QMessageBox::informativeText | ( | ) | const |
Returns the value of the property.
|
overrideprotectedvirtual |
Reimplemented from QDialog::keyPressEvent()
|
usingslot |
Shows the dialog as a window modal dialog, returning immediately.
Opens the dialog and connects its finished() or buttonClicked() signal to the slot specified by receiver and member. If the slot in member has a pointer for its first parameter the connection is to buttonClicked(), otherwise the connection is to finished().
The signal will be disconnected from the slot when the dialog is closed.
|
deprecatedstatic |
Displays a question message box with the given title and text, as well as one, two or three buttons. Returns the index of the button that was clicked (0, 1 or 2).
|
deprecatedstatic |
Opens a question message box with the given title and text. The dialog may have up to three buttons.
|
static |
Opens a question message box with the given title and text in front of the specified parent widget.
The standard buttons are added to the message box. The defaultButton specifies the button used when Enter is pressed. defaultButton must refer to a button that was given in buttons. If defaultButton is QMessageBox::NoButton, QMessageBox chooses a suitable default automatically.
Returns the identity of the standard button that was clicked. If Esc was pressed instead, the escape button is returned.
The message box is an application modal dialog box.
void QMessageBox::removeButton | ( | QAbstractButton * | button | ) |
Removes button from the button box without deleting it.
|
overrideprotectedvirtual |
Reimplemented from QDialog::resizeEvent()
|
deprecated |
Sets the text of the message box button to text. Setting the text of a button that is not in the message box is silently ignored.
void QMessageBox::setCheckBox | ( | QCheckBox * | cb | ) |
Sets the checkbox cb on the message dialog. The message box takes ownership of the checkbox. The given cb can be a nullptr which will remove an existing checkbox from the message box.
void QMessageBox::setDefaultButton | ( | QPushButton * | button | ) |
Sets the message box's default button to button.
void QMessageBox::setDefaultButton | ( | StandardButton | button | ) |
Sets the message box's default button to button.
void QMessageBox::setDetailedText | ( | const QString & | text | ) |
Sets the value of the property to text
void QMessageBox::setEscapeButton | ( | QAbstractButton * | button | ) |
Sets the button that gets activated when the Escape key is pressed to button.
void QMessageBox::setEscapeButton | ( | StandardButton | button | ) |
Sets the buttons that gets activated when the Escape key is pressed to button.
void QMessageBox::setIcon | ( | QMessageBox::Icon | icon | ) |
Sets the value of the property to icon.
void QMessageBox::setIconPixmap | ( | const QPixmap & | pixmap | ) |
Sets the value of the property to pixmap.
void QMessageBox::setInformativeText | ( | const QString & | text | ) |
Sets the value of the property to text.
void QMessageBox::setStandardButtons | ( | StandardButtons | buttons | ) |
Sets the value of the property to buttons.
void QMessageBox::setText | ( | const QString & | text | ) |
Sets the value of the property to text.
void QMessageBox::setTextFormat | ( | Qt::TextFormat | format | ) |
Sets the value of the property to format.
void QMessageBox::setTextInteractionFlags | ( | Qt::TextInteractionFlags | flags | ) |
Sets the value of the property to flags.
void QMessageBox::setWindowModality | ( | Qt::WindowModality | windowModality | ) |
Sets the modality of the message box to windowModality.
On Mac OS X, if the modality is set to window modal 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.
void QMessageBox::setWindowTitle | ( | const QString & | title | ) |
Sets the title of the message box to title. On Mac OS X, the window title is ignored (as required by the Mac OS X Guidelines).
|
overrideprotectedvirtual |
Reimplemented from QDialog::showEvent()
StandardButton QMessageBox::standardButton | ( | QAbstractButton * | button | ) | const |
Returns the standard button enum value corresponding to the given button, or NoButton if the given button is not a standard button.
StandardButtons QMessageBox::standardButtons | ( | ) | const |
Returns the value of the property.
Returns the pixmap used for a standard icon. This allows the pixmaps to be used in more complex message boxes. The icon specifies the required icon, e.g. QMessageBox::Question, QMessageBox::Information, QMessageBox::Warning or QMessageBox::Critical.
QString QMessageBox::text | ( | ) | const |
Returns the value of the property.
Qt::TextFormat QMessageBox::textFormat | ( | ) | const |
Returns the value of the property.
Qt::TextInteractionFlags QMessageBox::textInteractionFlags | ( | ) | const |
Returns the value of the property.
|
deprecatedstatic |
Displays a warning message box with the given title and text, as well as one, two, or three buttons. Returns the number of the button that was clicked (0, 1, or 2).
|
deprecatedstatic |
Opens a warning message box with the given title and text. The dialog may have up to three buttons.
|
static |
Opens a warning message box with the given title and text in front of the specified parent widget.
The standard buttons are added to the message box. The defaultButton specifies the button used when Enter is pressed. defaultButton must refer to a button that was given in buttons. If defaultButton is QMessageBox::NoButton, QMessageBox chooses a suitable default automatically.
Returns the identity of the standard button that was clicked. If Esc was pressed instead, the escape button is returned.
The message box is an application modal dialog box.
|
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.
Properties | Class Methods |
---|---|
read | detailedText |
write | setDetailedText |
|
This property holds the message box's icon. The default is QMessageBox::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 the icon pixmap property.
The icon of the message box can be specified with one of the following values.
Properties | Class Methods |
---|---|
read | icon |
write | setIcon |
|
This property holds the current icon. By default this property is undefined. The icon currently used by the message box. It is often hard to draw one pixmap which looks appropriate in all GUI styles. You may want to supply a different pixmap for each platform.
Properties | Class Methods |
---|---|
read | iconPixmap |
write | setIconPixmap |
|
This property holds the informative text that provides a fuller description for the message. By default this property contains an empty string.
Informative text can be used to expand upon the text() to give more information to the user. On the Mac, this text appears in small system font below the text(). On other platforms, it is simply appended to the existing text.
Properties | Class Methods |
---|---|
read | informativeText |
write | setInformativeText |
|
This property holds collection of standard buttons in the message box. By default this property contains no standard buttons. This property controls which standard buttons are used by the message box.
Properties | Class Methods |
---|---|
read | standardButtons |
write | setStandardButtons |
|
This property holds the message box text to be displayed. The default value of this property is an empty string.
The text will be interpreted either as a plain text or as rich text, depending on the text format setting (QMessageBox::textFormat). The default setting is Qt::AutoText, meaning the message box will try to auto detect the format of the text.
Properties | Class Methods |
---|---|
read | text |
write | setText |
|
This property holds the format of the text displayed by the message box. The default format is Qt::AutoText. The current text format used by the message box. See the Qt::TextFormat enum for an explanation of the possible options.
Properties | Class Methods |
---|---|
read | textFormat |
write | setTextFormat |