CopperSpice API  1.9.1
QMessageBox Class Reference

The QMessageBox class provides a modal dialog for informing the user or for asking the user a question and receiving an answer. More...

Inheritance diagram for QMessageBox:
QDialog QWidget QObject QPaintDevice

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 ()
 
QPushButtonaddButton (const QString &text, ButtonRole role)
 
void addButton (QAbstractButton *button, ButtonRole role)
 
QPushButtonaddButton (StandardButton button)
 
QAbstractButtonbutton (StandardButton which) const
 
ButtonRole buttonRole (QAbstractButton *button) const
 
QList< QAbstractButton * > buttons () const
 
QString buttonText (int button) const
 
QCheckBoxcheckBox () const
 
QAbstractButtonclickedButton () const
 
QPushButtondefaultButton () const
 
QString detailedText () const
 
QAbstractButtonescapeButton () 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 ()
 
QWidgetextension () 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
 
QBackingStorebackingStore () 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 QFontfont () const
 
QFontInfo fontInfo () const
 
QFontMetrics fontMetrics () const
 
QPalette::ColorRole foregroundRole () const
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () 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)
 
QGraphicsEffectgraphicsEffect () const
 
QGraphicsProxyWidgetgraphicsProxyWidget () 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
 
QLayoutlayout () 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)
 
QPaintEnginepaintEngine () const override
 
const QPalettepalette () 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 &region)
 
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 &region)
 
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
 
QStylestyle () 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 &region)
 
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
 
QWindowwindowHandle () 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< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, 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 QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
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)
 
QThreadthread () 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 QMetaObjectstaticMetaObject ()
 
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 ()
 

Properties

 detailedText
 
 icon
 
 iconPixmap
 
 informativeText
 
 standardButtons
 
 text
 
 textFormat
 
- Properties inherited from QDialog
 modal
 
 sizeGripEnabled
 
- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 toolTip
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Protected Slots inherited from QWidget
void updateMicroFocus ()
 

Detailed Description

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.

Using the Constructor API

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.

QMessageBox msgBox;
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 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.

QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
int returnValue = msgBox.exec();

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.

switch (returnValue) {
case QMessageBox::Save:
// Save was clicked
break;
case QMessageBox::Discard:
// Do not Save was clicked
break;
case QMessageBox::Cancel:
// Cancel was clicked
break;
default:
// should never be reached
break;
}

Examples

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.


Rich Text and the Text Format Property

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().

Severity Levels and the Icon and Pixmap Properties

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:

QuestionFor asking a question during normal operations.
InformationFor reporting information about normal operations.
WarningFor reporting non-critical errors.
CriticalFor 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.

Static Methods

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.

int retval = QMessageBox::warning(this, tr("My Application"),
tr("This document has been modified.\nDo you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);

Advanced Usage

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().

QMessageBox msgBox;
QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
msgBox.exec();
if (msgBox.clickedButton() == connectButton) {
// connect
} else if (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, 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:

  1. If there is only one button, it is the button activated when Esc is pressed.
  2. If there is a Cancel button, it is the button activated when Esc is pressed.
  3. If there is exactly one button having either the Reject role or the No role, it is the button activated when Esc is pressed.

When an escape button can not be determined using these rules, pressing Esc has no effect.

See also
QDialogButtonBox

Member Typedef Documentation

Member Enumeration 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.

ConstantValueDescription
QMessageBox::InvalidRole-1The button is invalid.
QMessageBox::AcceptRole0Clicking the button causes the dialog to be accepted (e.g. OK).
QMessageBox::RejectRole1Clicking the button causes the dialog to be rejected (e.g. Cancel).
QMessageBox::DestructiveRole2 Clicking the button causes a destructive change (e.g. for Discarding Changes) and closes the dialog.
QMessageBox::ActionRole3 Clicking the button causes changes to the elements within the dialog.
QMessageBox::HelpRole4The button can be clicked to request help.
QMessageBox::YesRole5The button is a "Yes"-like button.
QMessageBox::NoRole6The button is a "No"-like button.
QMessageBox::ResetRole7The button resets the dialog's fields to default values.
QMessageBox::ApplyRole8The button applies current changes.
See also
StandardButton

This enum has the following values:

ConstantValueDescription
QMessageBox::NoIcon0Message box does not have any icon.
QMessageBox::Information1Icon indicates the message is nothing out of the ordinary.
QMessageBox::Warning2Icon indicates the message is a warning, but can be dealt with.
QMessageBox::Critical3Icon indicates the message represents a critical problem.
QMessageBox::Question4Icon indicates the message is asking a question.

These enums describe flags for standard buttons. Each button has a defined ButtonRole.

ConstantValueDescription
QMessageBox::NoButton0x00000000Invalid 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::Abort0x00040000"Abort" button defined with the RejectRole.
QMessageBox::Retry0x00080000"Retry" button defined with the AcceptRole.
QMessageBox::Ignore0x00100000"Ignore" button defined with the AcceptRole.
QMessageBox::Close 0x00200000 "Close" button defined with the RejectRole.
QMessageBox::Cancel0x00400000 "Cancel" button defined with the RejectRole.
QMessageBox::Discard0x00800000 "Discard" or "Do not Save" button, depending on the platform, defined with the DestructiveRole.
QMessageBox::Help0x01000000"Help" button defined with the HelpRole.
QMessageBox::Apply0x02000000"Apply" button defined with the ApplyRole.
QMessageBox::Reset0x04000000"Reset" button defined with the ResetRole.
QMessageBox::RestoreDefaults0x08000000 "Restore Defaults" button defined with the ResetRole.

The following enum values are obsolete.

ConstantValueDescription
QMessageBox::YesAllYesToAllUse YesToAll instead.
QMessageBox::NoAllNoToAllUse NoToAll instead.
QMessageBox::Default0x00000100 Use the defaultButton argument for information(), warning()or call setDefaultButton().
QMessageBox::Escape0x00000200Call setEscapeButton() instead.
QMessageBox::FlagMask0x00000300 
QMessageBox::ButtonMask~FlagMask 

The StandardButtons type is a typedef for QFlags<StandardButton>. It stores an OR combination of StandardButton values.

See also
ButtonRole, standardButtons

Constructor & Destructor Documentation

QMessageBox::QMessageBox ( QWidget parent = nullptr)
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.

See also
setWindowTitle(), setText(), setIcon(), setStandardButtons()
QMessageBox::~QMessageBox ( )

Destroys the message box.

QMessageBox::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 
)
deprecated
Deprecated:
Use QMessageBox::QMessageBox() which uses the StandardButtons enum.

Constructs a message box with title, text, icon, and up to three buttons.

See also
setWindowTitle(), setText(), setIcon()

Method Documentation

void QMessageBox::about ( QWidget parent,
const QString title,
const QString text 
)
static

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.

  1. Prefers parent->icon() if this exists.
  2. If not, it tries the top-level widget containing parent.
  3. If that fails it tries the active window.
  4. As a last resort it uses the Information icon.
See also
QWidget::windowIcon(), QApplication::activeWindow()
void QMessageBox::aboutCs ( QWidget parent,
const QString title = QString() 
)
static

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.

See also
removeButton(), button(), setStandardButtons()
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.

See also
setStandardButtons()
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.

See also
standardButtons, standardButton()
void QMessageBox::buttonClicked ( QAbstractButton button)
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.

See also
buttons(), addButton()
QList< QAbstractButton * > QMessageBox::buttons ( ) const

Returns a list of all the buttons that have been added to the message box.

See also
buttonRole(), addButton(), removeButton()
QString QMessageBox::buttonText ( int  button) const
deprecated
Deprecated:
Use button() and QPushButton::text() instead.

Returns the text of the message box button or an empty string if the message box does not contain the button.

void QMessageBox::changeEvent ( QEvent event)
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.

QMessageBox messageBox(this);
QAbstractButton *disconnectButton = messageBox.addButton(tr("Disconnect"), QMessageBox::ActionRole);
messageBox.exec();
if (messageBox.clickedButton() == disconnectButton) {
// do something
}
See also
standardButton(), button()
void QMessageBox::closeEvent ( QCloseEvent event)
overrideprotectedvirtual

Reimplemented from QDialog::closeEvent()

int QMessageBox::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 
)
deprecatedstatic
Deprecated:
Use QMessageBox::critical() which uses the StandardButtons enum.

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).

See also
information(), question(), warning()
int QMessageBox::critical ( QWidget parent,
const QString title,
const QString text,
int  button0,
int  button1,
int  button2 = 0 
)
deprecatedstatic
Deprecated:
Use QMessageBox::critical() which uses the StandardButtons enum.

Opens a critical message box with the given title and text. The dialog may have up to three buttons.

See also
information(), question(), warning()
StandardButton QMessageBox::critical ( QWidget parent,
const QString title,
const QString text,
StandardButtons  buttons = Ok,
StandardButton  defaultButton = NoButton 
)
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.

Warning
Do not delete parent during the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the QMessageBox constructors.
See also
question(), warning(), information()
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.

See also
setDefaultButton(), addButton(), QPushButton::setDefault()
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.

  1. If there is only one button, it is made the escape button.
  2. If there is a Cancel button, it is made the escape button.
  3. On Mac OS X only, if there is exactly one button with the role QMessageBox::RejectRole, it is made the escape button.

When an escape button could not be automatically detected, pressing Esc has no effect.

See also
setEscapeButton(), addButton()
bool QMessageBox::event ( QEvent event)
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

See also
show(), result()
Icon QMessageBox::icon ( ) const

Returns the value of the property.

QPixmap QMessageBox::iconPixmap ( ) const

Returns the value of the property.

int QMessageBox::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 
)
deprecatedstatic
int QMessageBox::information ( QWidget parent,
const QString title,
const QString text,
int  button0,
int  button1 = 0,
int  button2 = 0 
)
deprecatedstatic
Deprecated:
Use QMessageBox::information() which uses the StandardButtons enum.

Opens an information message box with the given title and the text. The dialog may have up to three buttons.

See also
question(), warning(), critical()
StandardButton QMessageBox::information ( QWidget parent,
const QString title,
const QString text,
StandardButtons  buttons = Ok,
StandardButton  defaultButton = NoButton 
)
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.

Warning
Do not delete parent during the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the QMessageBox constructors.
See also
question(), warning(), critical()
QString QMessageBox::informativeText ( ) const

Returns the value of the property.

void QMessageBox::keyPressEvent ( QKeyEvent event)
overrideprotectedvirtual

Reimplemented from QDialog::keyPressEvent()

void QDialog::open ( )
usingslot

Shows the dialog as a window modal dialog, returning immediately.

See also
exec(), show(), result(), setWindowModality()
void QMessageBox::open ( QObject receiver,
const QString member 
)

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.

int QMessageBox::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 
)
deprecatedstatic
Deprecated:
Use QMessageBox::question() which uses the StandardButtons enum.

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).

See also
information(), warning(), critical()
int QMessageBox::question ( QWidget parent,
const QString title,
const QString text,
int  button0,
int  button1 = 0,
int  button2 = 0 
)
deprecatedstatic
Deprecated:
Use QMessageBox::question() which uses the StandardButtons enum.

Opens a question message box with the given title and text. The dialog may have up to three buttons.

See also
information(), warning(), critical()
StandardButton QMessageBox::question ( QWidget parent,
const QString title,
const QString text,
StandardButtons  buttons = StandardButtons(Yes | No),
StandardButton  defaultButton = NoButton 
)
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.

Warning
Do not delete parent during the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the QMessageBox constructors.
See also
information(), warning(), critical()
void QMessageBox::removeButton ( QAbstractButton button)

Removes button from the button box without deleting it.

See also
addButton(), setStandardButtons()
void QMessageBox::resizeEvent ( QResizeEvent event)
overrideprotectedvirtual

Reimplemented from QDialog::resizeEvent()

void QMessageBox::setButtonText ( int  button,
const QString text 
)
deprecated
Deprecated:
Use addButton() instead.

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.

See also
defaultButton(), addButton(), QPushButton::setDefault()
void QMessageBox::setDefaultButton ( StandardButton  button)

Sets the message box's default button to button.

See also
addButton(), QPushButton::setDefault()
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.

See also
escapeButton(), addButton(), clickedButton()
void QMessageBox::setEscapeButton ( StandardButton  button)

Sets the buttons that gets activated when the Escape key is pressed to button.

See also
addButton(), clickedButton()
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).

void QMessageBox::showEvent ( QShowEvent event)
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.

See also
button(), standardButtons()
StandardButtons QMessageBox::standardButtons ( ) const

Returns the value of the property.

QPixmap QMessageBox::standardIcon ( Icon  icon)
deprecatedstatic
Deprecated:
Call QStyle::standardIcon() with QStyle::SP_MessageBoxInformation etc. instead.

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.

int QMessageBox::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 
)
deprecatedstatic
Deprecated:
Use QMessageBox::warning() which uses the StandardButtons enum.

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).

See also
information(), question(), critical()
int QMessageBox::warning ( QWidget parent,
const QString title,
const QString text,
int  button0,
int  button1,
int  button2 = 0 
)
deprecatedstatic
Deprecated:
Use QMessageBox::warning() which uses the StandardButtons enum.

Opens a warning message box with the given title and text. The dialog may have up to three buttons.

See also
information(), question(), critical()
StandardButton QMessageBox::warning ( QWidget parent,
const QString title,
const QString text,
StandardButtons  buttons = Ok,
StandardButton  defaultButton = NoButton 
)
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.

Warning
Do not delete parent during the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the QMessageBox constructors.
See also
question(), information(), critical()

Property Documentation

QMessageBox::detailedText

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
QMessageBox::text, QMessageBox::informativeText
PropertiesClass Methods
read detailedText
write setDetailedText
QMessageBox::icon

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.

  • QMessageBox::NoIcon
  • QMessageBox::Question
  • QMessageBox::Information
  • QMessageBox::Warning
  • QMessageBox::Critical
See also
iconPixmap
PropertiesClass Methods
read icon
write setIcon
QMessageBox::iconPixmap

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.

See also
icon
PropertiesClass Methods
read iconPixmap
write setIconPixmap
QMessageBox::informativeText

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.

See also
QMessageBox::text, QMessageBox::detailedText
PropertiesClass Methods
read informativeText
write setInformativeText
QMessageBox::standardButtons

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.

See also
addButton()
PropertiesClass Methods
read standardButtons
write setStandardButtons
QMessageBox::text

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.

See also
textFormat, QMessageBox::informativeText, QMessageBox::detailedText
PropertiesClass Methods
read text
write setText
QMessageBox::textFormat

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.

See also
setText()
PropertiesClass Methods
read textFormat
write setTextFormat