Qt 4.8
|
The QMessageBox class provides a modal dialog for informing the user or for asking the user a question and receiving an answer. More...
#include <qmessagebox.h>
Public Types | |
typedef StandardButton | Button |
Use QMessageBox::StandardButton instead. More... | |
enum | ButtonRole { InvalidRole = -1, AcceptRole, RejectRole, DestructiveRole, ActionRole, HelpRole, YesRole, NoRole, ResetRole, ApplyRole, NRoles } |
Combinations of these roles are as flags used to describe different aspects of their behavior. More... | |
enum | Icon { NoIcon = 0, Information = 1, Warning = 2, Critical = 3, Question = 4 } |
This enum has the following values: More... | |
enum | StandardButton { NoButton = 0x00000000, Ok = 0x00000400, Save = 0x00000800, SaveAll = 0x00001000, Open = 0x00002000, Yes = 0x00004000, YesToAll = 0x00008000, No = 0x00010000, NoToAll = 0x00020000, Abort = 0x00040000, Retry = 0x00080000, Ignore = 0x00100000, Close = 0x00200000, Cancel = 0x00400000, Discard = 0x00800000, Help = 0x01000000, Apply = 0x02000000, Reset = 0x04000000, RestoreDefaults = 0x08000000, FirstButton = Ok, LastButton = RestoreDefaults, YesAll = YesToAll, NoAll = NoToAll, Default = 0x00000100, Escape = 0x00000200, FlagMask = 0x00000300, ButtonMask = ~FlagMask } |
These enums describe flags for standard buttons. More... | |
Public Types inherited from QDialog | |
enum | DialogCode { Rejected, Accepted } |
The value returned by a modal dialog. More... | |
Public Types inherited from QWidget | |
enum | RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 } |
This enum describes how to render the widget when calling QWidget::render(). More... | |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric { PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM, PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY, PdmPhysicalDpiX, PdmPhysicalDpiY } |
Public Slots | |
int | exec () |
Shows the message box as a modal dialog, blocking until the user closes it. More... | |
Public Slots inherited from QDialog | |
virtual void | accept () |
Hides the modal dialog and sets the result code to Accepted . More... | |
virtual void | done (int) |
Closes the dialog and sets its result code to r. More... | |
int | exec () |
Shows the dialog as a modal dialog, blocking until the user closes it. More... | |
void | open () |
Shows the dialog as a window modal dialog, returning immediately. More... | |
virtual void | reject () |
Hides the modal dialog and sets the result code to Rejected . More... | |
void | showExtension (bool) |
If showIt is true, the dialog's extension is shown; otherwise the extension is hidden. More... | |
Public Slots inherited from QWidget | |
bool | close () |
Closes this widget. More... | |
void | hide () |
Hides the widget. More... | |
void | lower () |
Lowers the widget to the bottom of the parent widget's stack. More... | |
void | raise () |
Raises this widget to the top of the parent widget's stack. More... | |
void | repaint () |
Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. More... | |
void | setDisabled (bool) |
Disables widget input events if disable is true; otherwise enables input events. More... | |
void | setEnabled (bool) |
void | setFocus () |
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More... | |
void | setHidden (bool hidden) |
Convenience function, equivalent to setVisible(!hidden). More... | |
QT_MOC_COMPAT void | setShown (bool shown) |
Use setVisible(shown) instead. More... | |
void | setStyleSheet (const QString &styleSheet) |
void | setWindowModified (bool) |
void | setWindowTitle (const QString &) |
void | show () |
Shows the widget and its child widgets. More... | |
void | showFullScreen () |
Shows the widget in full-screen mode. More... | |
void | showMaximized () |
Shows the widget maximized. More... | |
void | showMinimized () |
Shows the widget minimized, as an icon. More... | |
void | showNormal () |
Restores the widget after it has been maximized or minimized. More... | |
void | update () |
Updates the widget unless updates are disabled or the widget is hidden. More... | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Signals | |
void | buttonClicked (QAbstractButton *button) |
This signal is emitted whenever a button is clicked inside the QMessageBox. More... | |
Signals inherited from QDialog | |
void | accepted () |
This signal is emitted when the dialog has been accepted either by the user or by calling accept() or done() with the QDialog::Accepted argument. More... | |
void | finished (int result) |
This signal is emitted when the dialog's result code has been set, either by the user or by calling done(), accept(), or reject(). More... | |
void | rejected () |
This signal is emitted when the dialog has been rejected either by the user or by calling reject() or done() with the QDialog::Rejected argument. More... | |
Signals inherited from QWidget | |
void | customContextMenuRequested (const QPoint &pos) |
This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
void | addButton (QAbstractButton *button, ButtonRole role) |
Adds the given button to the message box with the specified role. More... | |
QPushButton * | 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 it. More... | |
QPushButton * | addButton (StandardButton button) |
Adds a standard button to the message box if it is valid to do so, and returns the push button. More... | |
QAbstractButton * | button (StandardButton which) const |
Returns a pointer corresponding to the standard button which, or 0 if the standard button doesn't exist in this message box. More... | |
ButtonRole | buttonRole (QAbstractButton *button) const |
Returns the button role for the specified button. More... | |
QList< QAbstractButton * > | buttons () const |
Returns a list of all the buttons that have been added to the message box. More... | |
QString | buttonText (int button) const |
Returns the text of the message box button button, or an empty string if the message box does not contain the button. More... | |
QAbstractButton * | clickedButton () const |
Returns the button that was clicked by the user, or 0 if the user hit the Esc key and no escape button was set. More... | |
QPushButton * | defaultButton () const |
Returns the button that should be the message box's default button. More... | |
QString | detailedText () const |
QAbstractButton * | escapeButton () const |
Returns the button that is activated when escape is pressed. More... | |
Icon | icon () const |
QPixmap | iconPixmap () const |
QString | informativeText () const |
void | open (QObject *receiver, const char *member) |
Opens the dialog and connects its finished() or buttonClicked() signal to the slot specified by receiver and member. More... | |
QMessageBox (QWidget *parent=0) | |
Constructs a message box with no text and no buttons. More... | |
QMessageBox (Icon icon, const QString &title, const QString &text, StandardButtons buttons=NoButton, QWidget *parent=0, Qt::WindowFlags flags=Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint) | |
Constructs a message box with the given icon, title, text, and standard buttons. More... | |
QMessageBox (const QString &title, const QString &text, Icon icon, int button0, int button1, int button2, QWidget *parent=0, Qt::WindowFlags f=Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint) | |
Constructs a message box with a title, a text, an icon, and up to three buttons. More... | |
void | removeButton (QAbstractButton *button) |
Removes button from the button box without deleting it. More... | |
void | setButtonText (int button, const QString &text) |
Sets the text of the message box button button to text. More... | |
void | setDefaultButton (QPushButton *button) |
Sets the message box's default button to button. More... | |
void | setDefaultButton (StandardButton button) |
Sets the message box's default button to button. More... | |
void | setDetailedText (const QString &text) |
void | setEscapeButton (QAbstractButton *button) |
Sets the button that gets activated when the Escape key is pressed to button. More... | |
void | setEscapeButton (StandardButton button) |
Sets the buttons that gets activated when the Escape key is pressed to button. More... | |
void | setIcon (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 | setVisible (bool visible) |
Reimplemented Function More... | |
void | setWindowModality (Qt::WindowModality windowModality) |
This function shadows QWidget::setWindowModality(). More... | |
void | setWindowTitle (const QString &title) |
This function shadows QWidget::setWindowTitle(). More... | |
QSize | sizeHint () const |
StandardButton | standardButton (QAbstractButton *button) const |
Returns the standard button enum value corresponding to the given button, or NoButton if the given button isn't a standard button. More... | |
StandardButtons | standardButtons () const |
QString | text () const |
Qt::TextFormat | textFormat () const |
~QMessageBox () | |
Destroys the message box. More... | |
Public Functions inherited from QDialog | |
QWidget * | extension () const |
Returns the dialog's extension or 0 if no extension has been defined. More... | |
bool | isSizeGripEnabled () const |
QSize | minimumSizeHint () const |
Reimplemented Function More... | |
Qt::Orientation | orientation () const |
Returns the dialog's extension orientation. More... | |
QDialog (QWidget *parent=0, Qt::WindowFlags f=0) | |
Constructs a dialog with parent parent. More... | |
int | result () const |
In general returns the modal dialog's result code, Accepted or Rejected . More... | |
void | setExtension (QWidget *extension) |
Sets the widget, extension, to be the dialog's extension, deleting any previous extension. More... | |
void | setModal (bool modal) |
void | setOrientation (Qt::Orientation orientation) |
If orientation is Qt::Horizontal, the extension will be displayed to the right of the dialog's main area. More... | |
void | setResult (int r) |
Sets the modal dialog's result code to i. More... | |
void | setSizeGripEnabled (bool) |
~QDialog () | |
Destroys the QDialog, deleting all its children. More... | |
Public Functions inherited from QWidget | |
bool | acceptDrops () const |
QString | accessibleDescription () const |
QString | accessibleName () const |
QList< QAction * > | actions () const |
Returns the (possibly empty) list of this widget's actions. More... | |
void | activateWindow () |
Sets the top-level widget containing this widget to be the active window. More... | |
void | addAction (QAction *action) |
Appends the action action to this widget's list of actions. More... | |
void | addActions (QList< QAction *> actions) |
Appends the actions actions to this widget's list of actions. More... | |
void | adjustSize () |
Adjusts the size of the widget to fit its contents. More... | |
bool | autoFillBackground () const |
QPalette::ColorRole | backgroundRole () const |
Returns the background role of the widget. More... | |
QSize | baseSize () const |
QWidget * | childAt (int x, int y) const |
Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system. More... | |
QWidget * | childAt (const QPoint &p) const |
Returns the visible child widget at point p in the widget's own coordinate system. More... | |
QRect | childrenRect () const |
QRegion | childrenRegion () const |
void | clearFocus () |
Takes keyboard input focus from the widget. More... | |
void | clearMask () |
Removes any mask set by setMask(). More... | |
QMargins | contentsMargins () const |
The contentsMargins function returns the widget's contents margins. More... | |
QRect | contentsRect () const |
Returns the area inside the widget's margins. More... | |
Qt::ContextMenuPolicy | contextMenuPolicy () const |
void | createWinId () |
QCursor | cursor () const |
int | devType () const |
WId | effectiveWinId () const |
Returns the effective window system identifier of the widget, i. More... | |
void | ensurePolished () const |
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). More... | |
Qt::FocusPolicy | focusPolicy () const |
QWidget * | focusProxy () const |
Returns the focus proxy, or 0 if there is no focus proxy. More... | |
QWidget * | focusWidget () const |
Returns the last child of this widget that setFocus had been called on. More... | |
const QFont & | font () const |
QFontInfo | fontInfo () const |
Returns the font info for the widget's current font. More... | |
QFontMetrics | fontMetrics () const |
Returns the font metrics for the widget's current font. More... | |
QPalette::ColorRole | foregroundRole () const |
Returns the foreground role. More... | |
QRect | frameGeometry () const |
QSize | frameSize () const |
const QRect & | geometry () const |
void | getContentsMargins (int *left, int *top, int *right, int *bottom) const |
Returns the widget's contents margins for left, top, right, and bottom. More... | |
HDC | getDC () const |
Returns the window system handle of the widget, for low-level access. More... | |
void | grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags()) |
Subscribes the widget to a given gesture with specific flags. More... | |
void | grabKeyboard () |
Grabs the keyboard input. More... | |
void | grabMouse () |
Grabs the mouse input. More... | |
void | grabMouse (const QCursor &) |
int | grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut) |
Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. More... | |
QGraphicsEffect * | graphicsEffect () const |
The graphicsEffect function returns a pointer to the widget's graphics effect. More... | |
QGraphicsProxyWidget * | graphicsProxyWidget () const |
Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns 0. More... | |
bool | hasFocus () const |
bool | hasMouseTracking () const |
int | height () const |
virtual int | heightForWidth (int) const |
Returns the preferred height for this widget, given the width w. More... | |
QInputContext * | inputContext () |
This function returns the QInputContext for this widget. More... | |
Qt::InputMethodHints | inputMethodHints () const |
virtual QVariant | inputMethodQuery (Qt::InputMethodQuery) const |
This method is only relevant for input widgets. More... | |
void | insertAction (QAction *before, QAction *action) |
Inserts the action action to this widget's list of actions, before the action before. More... | |
void | insertActions (QAction *before, QList< QAction *> actions) |
Inserts the actions actions to this widget's list of actions, before the action before. More... | |
WId | internalWinId () const |
Returns the window system identifier of the widget, or 0 if the widget is not created yet. More... | |
bool | isActiveWindow () const |
bool | isAncestorOf (const QWidget *child) const |
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window; otherwise returns false. More... | |
bool | isEnabled () const |
bool | isEnabledTo (QWidget *) const |
Returns true if this widget would become enabled if ancestor is enabled; otherwise returns false. More... | |
bool | isEnabledToTLW () const |
This function is deprecated. More... | |
bool | isFullScreen () const |
bool | isHidden () const |
Returns true if the widget is hidden, otherwise returns false. More... | |
bool | isLeftToRight () const |
bool | isMaximized () const |
bool | isMinimized () const |
bool | isModal () const |
bool | isRightToLeft () const |
bool | isTopLevel () const |
Use isWindow() instead. More... | |
bool | isVisible () const |
bool | isVisibleTo (QWidget *) const |
Returns true if this widget would become visible if ancestor is shown; otherwise returns false. More... | |
bool | isWindow () const |
Returns true if the widget is an independent window, otherwise returns false. More... | |
bool | isWindowModified () const |
QLayout * | layout () const |
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed. More... | |
Qt::LayoutDirection | layoutDirection () const |
QLocale | locale () const |
Qt::HANDLE | macCGHandle () const |
Returns the CoreGraphics handle of the widget. More... | |
Qt::HANDLE | macQDHandle () const |
Returns the QuickDraw handle of the widget. More... | |
QPoint | mapFrom (QWidget *, const QPoint &) const |
Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. More... | |
QPoint | mapFromGlobal (const QPoint &) const |
Translates the global screen coordinate pos to widget coordinates. More... | |
QPoint | mapFromParent (const QPoint &) const |
Translates the parent widget coordinate pos to widget coordinates. More... | |
QPoint | mapTo (QWidget *, const QPoint &) const |
Translates the widget coordinate pos to the coordinate system of parent. More... | |
QPoint | mapToGlobal (const QPoint &) const |
Translates the widget coordinate pos to global screen coordinates. More... | |
QPoint | mapToParent (const QPoint &) const |
Translates the widget coordinate pos to a coordinate in the parent widget. More... | |
QRegion | mask () const |
Returns the mask currently set on a widget. More... | |
int | maximumHeight () const |
QSize | maximumSize () const |
int | maximumWidth () const |
int | minimumHeight () const |
QSize | minimumSize () const |
int | minimumWidth () const |
void | move (int x, int y) |
This corresponds to move(QPoint(x, y)). More... | |
void | move (const QPoint &) |
QWidget * | nativeParentWidget () const |
Returns the native parent for this widget, i. More... | |
QWidget * | nextInFocusChain () const |
Returns the next widget in this widget's focus chain. More... | |
QRect | normalGeometry () const |
void | overrideWindowFlags (Qt::WindowFlags type) |
Sets the window flags for the widget to flags, without telling the window system. More... | |
void | overrideWindowState (Qt::WindowStates state) |
QPaintEngine * | paintEngine () const |
Returns the widget's paint engine. More... | |
const QPalette & | palette () const |
QWidget * | parentWidget () const |
Returns the parent of this widget, or 0 if it does not have any parent widget. More... | |
QPoint | pos () const |
QWidget * | previousInFocusChain () const |
The previousInFocusChain function returns the previous widget in this widget's focus chain. More... | |
QWidget (QWidget *parent=0, Qt::WindowFlags f=0) | |
Constructs a widget which is a child of parent, with widget flags set to f. More... | |
QRect | rect () const |
void | releaseDC (HDC) const |
Releases the HDC hdc acquired by a previous call to getDC(). More... | |
void | releaseKeyboard () |
Releases the keyboard grab. More... | |
void | releaseMouse () |
Releases the mouse grab. More... | |
void | releaseShortcut (int id) |
Removes the shortcut with the given id from Qt's shortcut system. More... | |
void | removeAction (QAction *action) |
Removes the action action from this widget's list of actions. More... | |
void | render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren)) |
Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. More... | |
void | render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren)) |
Renders the widget into the painter's QPainter::device(). More... | |
void | repaint (int x, int y, int w, int h) |
This version repaints a rectangle (x, y, w, h) inside the widget. More... | |
void | repaint (const QRect &) |
This version repaints a rectangle rect inside the widget. More... | |
void | repaint (const QRegion &) |
This version repaints a region rgn inside the widget. More... | |
void | resize (int w, int h) |
This corresponds to resize(QSize(w, h)). More... | |
void | resize (const QSize &) |
bool | restoreGeometry (const QByteArray &geometry) |
Restores the geometry and state top-level widgets stored in the byte array geometry. More... | |
QByteArray | saveGeometry () const |
Saves the current geometry and state for top-level widgets. More... | |
void | scroll (int dx, int dy) |
Scrolls the widget including its children dx pixels to the right and dy downward. More... | |
void | scroll (int dx, int dy, const QRect &) |
This version only scrolls r and does not move the children of the widget. More... | |
void | setAcceptDrops (bool on) |
void | setAccessibleDescription (const QString &description) |
void | setAccessibleName (const QString &name) |
void | setAttribute (Qt::WidgetAttribute, bool on=true) |
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute. More... | |
void | setAutoFillBackground (bool enabled) |
void | setBackgroundRole (QPalette::ColorRole) |
Sets the background role of the widget to role. More... | |
void | setBaseSize (const QSize &) |
void | setBaseSize (int basew, int baseh) |
This corresponds to setBaseSize(QSize(basew, baseh)). More... | |
void | setContentsMargins (int left, int top, int right, int bottom) |
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. More... | |
void | setContentsMargins (const QMargins &margins) |
The setContentsMargins function sets the margins around the widget's contents. More... | |
void | setContextMenuPolicy (Qt::ContextMenuPolicy policy) |
void | setCursor (const QCursor &) |
void | setFixedHeight (int h) |
Sets both the minimum and maximum heights of the widget to h without changing the widths. More... | |
void | setFixedSize (const QSize &) |
Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking. More... | |
void | setFixedSize (int w, int h) |
Sets the width of the widget to w and the height to h. More... | |
void | setFixedWidth (int w) |
Sets both the minimum and maximum width of the widget to w without changing the heights. More... | |
void | setFocus (Qt::FocusReason reason) |
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More... | |
void | setFocusPolicy (Qt::FocusPolicy policy) |
void | setFocusProxy (QWidget *) |
Sets the widget's focus proxy to widget w. More... | |
void | setFont (const QFont &) |
Use the single-argument overload instead. More... | |
void | setForegroundRole (QPalette::ColorRole) |
Sets the foreground role of the widget to role. More... | |
void | setGeometry (int x, int y, int w, int h) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This corresponds to setGeometry(QRect(x, y, w, h)). More... | |
void | setGeometry (const QRect &) |
void | setGraphicsEffect (QGraphicsEffect *effect) |
The setGraphicsEffect function is for setting the widget's graphics effect. More... | |
void | setInputContext (QInputContext *) |
This function sets the input context context on this widget. More... | |
void | setInputMethodHints (Qt::InputMethodHints hints) |
void | setLayout (QLayout *) |
Sets the layout manager for this widget to layout. More... | |
void | setLayoutDirection (Qt::LayoutDirection direction) |
void | setLocale (const QLocale &locale) |
void | setMask (const QBitmap &) |
Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. More... | |
void | setMask (const QRegion &) |
Causes only the parts of the widget which overlap region to be visible. More... | |
void | setMaximumHeight (int maxh) |
void | setMaximumSize (const QSize &) |
void | setMaximumSize (int maxw, int maxh) |
This function corresponds to setMaximumSize(QSize(maxw, maxh)). More... | |
void | setMaximumWidth (int maxw) |
void | setMinimumHeight (int minh) |
void | setMinimumSize (const QSize &) |
void | setMinimumSize (int minw, int minh) |
This function corresponds to setMinimumSize(QSize(minw, minh)). More... | |
void | setMinimumWidth (int minw) |
void | setMouseTracking (bool enable) |
void | setPalette (const QPalette &) |
Use the single-argument overload instead. More... | |
void | setParent (QWidget *parent) |
Sets the parent of the widget to parent, and resets the window flags. More... | |
void | setParent (QWidget *parent, Qt::WindowFlags f) |
This function also takes widget flags, f as an argument. More... | |
void | setShortcutAutoRepeat (int id, bool enable=true) |
If enable is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled. More... | |
void | setShortcutEnabled (int id, bool enable=true) |
If enable is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled. More... | |
void | setSizeIncrement (const QSize &) |
void | setSizeIncrement (int w, int h) |
Sets the x (width) size increment to w and the y (height) size increment to h. More... | |
void | setSizePolicy (QSizePolicy) |
void | setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) |
Sets the size policy of the widget to horizontal and vertical, with standard stretch and no height-for-width. More... | |
void | setStatusTip (const QString &) |
void | setStyle (QStyle *) |
Sets the widget's GUI style to style. More... | |
void | setToolTip (const QString &) |
void | setUpdatesEnabled (bool enable) |
void | setupUi (QWidget *widget) |
Sets up the user interface for the specified widget. More... | |
void | setWhatsThis (const QString &) |
void | setWindowFilePath (const QString &filePath) |
void | setWindowFlags (Qt::WindowFlags type) |
void | setWindowIcon (const QIcon &icon) |
void | setWindowIconText (const QString &) |
void | setWindowModality (Qt::WindowModality windowModality) |
void | setWindowOpacity (qreal level) |
void | setWindowRole (const QString &) |
Sets the window's role to role. More... | |
void | setWindowState (Qt::WindowStates state) |
Sets the window state to windowState. More... | |
void | setWindowSurface (QWindowSurface *surface) |
Sets the window surface to be the surface specified. More... | |
QSize | size () const |
QSize | sizeIncrement () const |
QSizePolicy | sizePolicy () const |
void | stackUnder (QWidget *) |
Places the widget under w in the parent widget's stack. More... | |
QString | statusTip () const |
QStyle * | style () const |
QString | styleSheet () const |
bool | testAttribute (Qt::WidgetAttribute) const |
Returns true if attribute attribute is set on this widget; otherwise returns false. More... | |
QString | toolTip () const |
QWidget * | topLevelWidget () const |
bool | underMouse () const |
Returns true if the widget is under the mouse cursor; otherwise returns false. More... | |
void | ungrabGesture (Qt::GestureType type) |
Unsubscribes the widget from a given gesture type. More... | |
void | unsetCursor () |
void | unsetLayoutDirection () |
void | unsetLocale () |
void | update (int x, int y, int w, int h) |
This version updates a rectangle (x, y, w, h) inside the widget. More... | |
void | update (const QRect &) |
This version updates a rectangle rect inside the widget. More... | |
void | update (const QRegion &) |
This version repaints a region rgn inside the widget. More... | |
void | updateGeometry () |
Notifies the layout system that this widget has changed and may need to change geometry. More... | |
bool | updatesEnabled () const |
QRegion | visibleRegion () const |
Returns the unobscured region where paint events can occur. More... | |
QString | whatsThis () const |
int | width () const |
QWidget * | window () const |
Returns the window for this widget, i.e. More... | |
QString | windowFilePath () const |
Qt::WindowFlags | windowFlags () const |
Window flags are a combination of a type (e. More... | |
QIcon | windowIcon () const |
QString | windowIconText () const |
Qt::WindowModality | windowModality () const |
qreal | windowOpacity () const |
QString | windowRole () const |
Returns the window's role, or an empty string. More... | |
Qt::WindowStates | windowState () const |
Returns the current window state. More... | |
QWindowSurface * | windowSurface () const |
Returns the QWindowSurface this widget will be drawn into. More... | |
QString | windowTitle () const |
Qt::WindowType | windowType () const |
Returns the window type of this widget. More... | |
WId | winId () const |
Returns the window system identifier of the widget. More... | |
int | x () const |
const QX11Info & | x11Info () const |
Returns information about the configuration of the X display used to display the widget. More... | |
Qt::HANDLE | x11PictureHandle () const |
Returns the X11 Picture handle of the widget for XRender support. More... | |
int | y () const |
~QWidget () | |
Destroys the widget. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Public Functions inherited from QPaintDevice | |
int | colorCount () const |
int | depth () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
QT_DEPRECATED int | numColors () const |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
int | width () const |
int | widthMM () const |
virtual | ~QPaintDevice () |
Static Public Functions | |
static void | about (QWidget *parent, const QString &title, const QString &text) |
Displays a simple about box with title title and text text. More... | |
static void | aboutQt (QWidget *parent, const QString &title=QString()) |
Displays a simple message box about Qt, with the given title and centered over parent (if parent is not 0). More... | |
static StandardButton | critical (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
Opens a critical message box with the given title and text in front of the specified parent widget. More... | |
static int | critical (QWidget *parent, const QString &title, const QString &text, int button0, int button1, int button2=0) |
Opens a critical message box with the given title and text. More... | |
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) |
Displays a critical error message box with the given title and text, as well as one, two, or three buttons. More... | |
static int | critical (QWidget *parent, const QString &title, const QString &text, StandardButton button0, StandardButton button1) |
static StandardButton | information (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
Opens an information message box with the given title and text in front of the specified parent widget. More... | |
static int | information (QWidget *parent, const QString &title, const QString &text, int button0, int button1=0, int button2=0) |
Opens an information message box with the given title and the text. More... | |
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) |
Displays an information message box with the given title and text, as well as one, two or three buttons. More... | |
static StandardButton | information (QWidget *parent, const QString &title, const QString &text, StandardButton button0, StandardButton button1=NoButton) |
static StandardButton | question (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
Opens a question message box with the given title and text in front of the specified parent widget. More... | |
static int | question (QWidget *parent, const QString &title, const QString &text, int button0, int button1=0, int button2=0) |
Opens a question message box with the given title and text. More... | |
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) |
Displays a question message box with the given title and text, as well as one, two or three buttons. More... | |
static int | question (QWidget *parent, const QString &title, const QString &text, StandardButton button0, StandardButton button1) |
static QPixmap | standardIcon (Icon icon) |
Returns the pixmap used for a standard icon. More... | |
static StandardButton | warning (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
Opens a warning message box with the given title and text in front of the specified parent widget. More... | |
static int | warning (QWidget *parent, const QString &title, const QString &text, int button0, int button1, int button2=0) |
Opens a warning message box with the given title and text. More... | |
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) |
Displays a warning message box with the given title and text, as well as one, two, or three buttons. More... | |
static int | warning (QWidget *parent, const QString &title, const QString &text, StandardButton button0, StandardButton button1) |
Static Public Functions inherited from QWidget | |
static QWidget * | find (WId) |
Returns a pointer to the widget with window identifer/handle id. More... | |
static QWidget * | keyboardGrabber () |
Returns the widget that is currently grabbing the keyboard input. More... | |
static QWidget * | mouseGrabber () |
Returns the widget that is currently grabbing the mouse input. More... | |
static void | setTabOrder (QWidget *, QWidget *) |
Puts the second widget after the first widget in the focus order. More... | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Functions inherited from QPaintDevice | |
static QWSDisplay * | qwsDisplay () |
Protected Functions | |
void | changeEvent (QEvent *event) |
Reimplemented Function More... | |
void | closeEvent (QCloseEvent *event) |
Reimplemented Function More... | |
bool | event (QEvent *e) |
Reimplemented Function More... | |
void | keyPressEvent (QKeyEvent *event) |
Reimplemented Function More... | |
void | resizeEvent (QResizeEvent *event) |
Reimplemented Function More... | |
void | showEvent (QShowEvent *event) |
Reimplemented Function More... | |
Protected Functions inherited from QDialog | |
void | adjustPosition (QWidget *) |
void | contextMenuEvent (QContextMenuEvent *) |
Reimplemented Function More... | |
bool | eventFilter (QObject *, QEvent *) |
Reimplemented Function More... | |
QDialog (QDialogPrivate &, QWidget *parent, Qt::WindowFlags f=0) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
Protected Functions inherited from QWidget | |
virtual void | actionEvent (QActionEvent *) |
This event handler is called with the given event whenever the widget's actions are changed. More... | |
void | create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true) |
Creates a new widget window if window is 0, otherwise sets the widget's window to window. More... | |
void | destroy (bool destroyWindow=true, bool destroySubWindows=true) |
Frees up window system resources. More... | |
virtual void | dragEnterEvent (QDragEnterEvent *) |
This event handler is called when a drag is in progress and the mouse enters this widget. More... | |
virtual void | dragLeaveEvent (QDragLeaveEvent *) |
This event handler is called when a drag is in progress and the mouse leaves this widget. More... | |
virtual void | dragMoveEvent (QDragMoveEvent *) |
This event handler is called if a drag is in progress, and when any of the following conditions occur: the cursor enters this widget, the cursor moves within this widget, or a modifier key is pressed on the keyboard while this widget has the focus. More... | |
virtual void | dropEvent (QDropEvent *) |
This event handler is called when the drag is dropped on this widget. More... | |
virtual void | enabledChange (bool) |
virtual void | enterEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive widget enter events which are passed in the event parameter. More... | |
bool | event (QEvent *) |
This is the main event handler; it handles event event. More... | |
virtual void | focusInEvent (QFocusEvent *) |
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. More... | |
bool | focusNextChild () |
Finds a new widget to give the keyboard focus to, as appropriate for Tab, and returns true if it can find a new widget, or false if it can't. More... | |
virtual bool | focusNextPrevChild (bool next) |
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can't. More... | |
virtual void | focusOutEvent (QFocusEvent *) |
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget. More... | |
bool | focusPreviousChild () |
Finds a new widget to give the keyboard focus to, as appropriate for Shift+Tab, and returns true if it can find a new widget, or false if it can't. More... | |
virtual void | fontChange (const QFont &) |
virtual void | hideEvent (QHideEvent *) |
This event handler can be reimplemented in a subclass to receive widget hide events. More... | |
virtual void | inputMethodEvent (QInputMethodEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive Input Method composition events. More... | |
virtual void | keyReleaseEvent (QKeyEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive key release events for the widget. More... | |
virtual void | languageChange () |
virtual void | leaveEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive widget leave events which are passed in the event parameter. More... | |
virtual bool | macEvent (EventHandlerCallRef, EventRef) |
This special event handler can be reimplemented in a subclass to receive native Macintosh events. More... | |
int | metric (PaintDeviceMetric) const |
Internal implementation of the virtual QPaintDevice::metric() function. More... | |
virtual void | mouseDoubleClickEvent (QMouseEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive mouse double click events for the widget. More... | |
virtual void | mouseMoveEvent (QMouseEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events for the widget. More... | |
virtual void | mousePressEvent (QMouseEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events for the widget. More... | |
virtual void | mouseReleaseEvent (QMouseEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive mouse release events for the widget. More... | |
virtual void | moveEvent (QMoveEvent *) |
This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter. More... | |
virtual void | paintEvent (QPaintEvent *) |
This event handler can be reimplemented in a subclass to receive paint events passed in event. More... | |
virtual void | paletteChange (const QPalette &) |
QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f) | |
virtual bool | qwsEvent (QWSEvent *) |
This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux events which are passed in the event parameter. More... | |
void | resetInputContext () |
This function can be called on the widget that currently has focus to reset the input method operating on it. More... | |
virtual void | styleChange (QStyle &) |
virtual void | tabletEvent (QTabletEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive tablet events for the widget. More... | |
virtual void | wheelEvent (QWheelEvent *) |
This event handler, for event event, can be reimplemented in a subclass to receive wheel events for the widget. More... | |
virtual void | windowActivationChange (bool) |
virtual bool | winEvent (MSG *message, long *result) |
This special event handler can be reimplemented in a subclass to receive native Windows events which are passed in the message parameter. More... | |
virtual bool | x11Event (XEvent *) |
This special event handler can be reimplemented in a subclass to receive native X11 events passed in the event parameter. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Protected Functions inherited from QPaintDevice | |
QPaintDevice () | |
Properties | |
QString | detailedText |
the text to be displayed in the details area. More... | |
Icon | icon |
the message box's icon More... | |
QPixmap | iconPixmap |
the current icon More... | |
QString | informativeText |
the informative text that provides a fuller description for the message More... | |
StandardButtons | standardButtons |
collection of standard buttons in the message box More... | |
QString | text |
the message box text to be displayed. More... | |
Qt::TextFormat | textFormat |
the format of the text displayed by the message box More... | |
Additional Inherited Members | |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Slots inherited from QWidget | |
void | updateMicroFocus () |
Updates the widget's micro focus. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Protected Variables inherited from QPaintDevice | |
ushort | painters |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QWidget | |
QWidgetList | |
WId | |
Platform dependent window identifier. More... | |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
Related Functions inherited from QPaintDevice | |
const Q_GUI_EXPORT QX11Info * | qt_x11Info (const QPaintDevice *pd) |
Returns the QX11Info structure for the pd paint device. More... | |
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.
Two APIs for using QMessageBox are provided, the property-based API, and the static functions. Calling one of the static functions is the simpler approach, but it is less flexible than using the property-based API, and the result is less informative. Using the property-based API is recommended.
To use the property-based API, construct an instance of QMessageBox, set the desired properties, and 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 than just alerting the user to an event is to also ask the user what to do about it. Store the question in the informative text property, and set the standard buttons property to the set of buttons you want as the set of user responses. The buttons are specified by combining values from StandardButtons using the bitwise OR operator. The display order for the buttons is platform-dependent. For example, on Windows, Save is displayed to the left of Cancel, whereas on Mac OS, the order is reversed.
Mark one of your standard buttons to be your default button.
This is the approach recommended in the Mac 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.
To give the user more information to help him answer the question, set the detailed text property. If the detailed text property is set, the Show Details... button will be shown.
Clicking the Show Details... button displays the detailed text.
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.
The Standard Dialogs example shows how to use QMessageBox and the other built-in Qt dialogs.
If the standard buttons are not flexible enough for your message box, you can use the addButton() overload that takes a text and a ButtonRoleto 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(). For example,
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:
If there is only one button, it is the button activated when Esc is pressed.
If there is a Cancel button, it is the button activated when Esc is pressed.
If there is exactly one button having either the Reject role or the the No role, it is the button activated when Esc is pressed.
When an escape button can't be determined using these rules, pressing Esc has no effect.
Definition at line 59 of file qmessagebox.h.
Use QMessageBox::StandardButton instead.
Definition at line 133 of file qmessagebox.h.
Combinations of these roles are as flags used to describe different aspects of their behavior.
Enumerator | |
---|---|
InvalidRole | |
AcceptRole | |
RejectRole | |
DestructiveRole | |
ActionRole | |
HelpRole | |
YesRole | |
NoRole | |
ResetRole | |
ApplyRole | |
NRoles |
Definition at line 84 of file qmessagebox.h.
enum QMessageBox::Icon |
This enum has the following values:
Enumerator | |
---|---|
NoIcon | |
Information | |
Warning | |
Critical | |
Question |
Definition at line 76 of file qmessagebox.h.
These enums describe flags for standard buttons.
Each button has a defined ButtonRole .
The following values are obsolete:
defaultButton
argument of information(), warning(), etc. instead, or call setDefaultButton(). Definition at line 100 of file qmessagebox.h.
|
explicit |
Constructs a message box with no text and no buttons.
parent is passed to the QDialog constructor.
On Mac OS X, if you want your message box to appear as a Qt::Sheet of its parent, set the message box's window modality to Qt::WindowModal or use open(). Otherwise, the message box will be a standard dialog.
Definition at line 776 of file qmessagebox.cpp.
Referenced by about(), aboutQt(), and setWindowModality().
QMessageBox::QMessageBox | ( | Icon | icon, |
const QString & | title, | ||
const QString & | text, | ||
StandardButtons | buttons = NoButton , |
||
QWidget * | parent = 0 , |
||
Qt::WindowFlags | f = 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 f arguments are passed to the QDialog constructor.
The message box is an application modal dialog box.
On Mac OS X, if parent is not 0 and you want your message box to appear as a Qt::Sheet of that parent, set the message box's window modality to Qt::WindowModal (default). Otherwise, the message box will be a standard dialog.
Definition at line 799 of file qmessagebox.cpp.
QMessageBox::~QMessageBox | ( | ) |
QMessageBox::QMessageBox | ( | const QString & | title, |
const QString & | text, | ||
Icon | icon, | ||
int | button0, | ||
int | button1, | ||
int | button2, | ||
QWidget * | parent = 0 , |
||
Qt::WindowFlags | f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint |
||
) |
Constructs a message box with a title, a text, an icon, and up to three buttons.
The icon must be one of the following:
Each button, button0, button1 and button2, can have one of the following values:
Use QMessageBox::NoButton for the later parameters to have fewer than three buttons in your message box. If you don't specify any buttons at all, QMessageBox will provide an Ok button.
One of the buttons can be OR-ed with the QMessageBox::Default flag to make it the default button (clicked when Enter is pressed).
One of the buttons can be OR-ed with the QMessageBox::Escape flag to make it the cancel or close button (clicked when Esc is pressed).
The message box is an application modal dialog box.
The parent and f arguments are passed to the QDialog constructor.
Definition at line 2093 of file qmessagebox.cpp.
Displays a simple about box with title title and text text.
The about box's parent is parent.
about() looks for a suitable icon in four locations:
The about box has a single button labelled "OK". On Mac OS X, the about box is popped up as a modeless window; on other platforms, it is currently application modal.
Definition at line 1773 of file qmessagebox.cpp.
Displays a simple message box about Qt, with the given title and centered over parent (if parent is not 0).
The message includes the version number of Qt being used by the application.
This is useful for inclusion in the Help menu of an application, as shown in the Menus example.
QApplication provides this functionality as a slot.
On Mac OS X, the about box is popped up as a modeless window; on other platforms, it is currently application modal.
Definition at line 1826 of file qmessagebox.cpp.
Referenced by QApplication::aboutQt(), and QApplicationPrivate::globalEventProcessor().
void QMessageBox::addButton | ( | QAbstractButton * | button, |
ButtonRole | role | ||
) |
Adds the given button to the message box with the specified role.
Definition at line 829 of file qmessagebox.cpp.
Referenced by aboutQt(), addButton(), setButtonText(), showEvent(), showNewMessageBox(), and QMessageBoxPrivate::showOldMessageBox().
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 it.
Definition at line 850 of file qmessagebox.cpp.
QPushButton * QMessageBox::addButton | ( | StandardButton | button | ) |
Adds a standard button to the message box if it is valid to do so, and returns the push button.
Definition at line 871 of file qmessagebox.cpp.
QAbstractButton * QMessageBox::button | ( | StandardButton | which | ) | const |
Returns a pointer corresponding to the standard button which, or 0 if the standard button doesn't exist in this message box.
Definition at line 964 of file qmessagebox.cpp.
Referenced by QMessageBoxPrivate::findButton(), setDefaultButton(), and showNewMessageBox().
|
signal |
This signal is emitted whenever a button is clicked inside the QMessageBox.
The button that was clicked in returned in button.
Referenced by open().
QMessageBox::ButtonRole QMessageBox::buttonRole | ( | QAbstractButton * | button | ) | const |
Returns the button role for the specified button.
This function returns InvalidRole if button is 0 or has not been added to the message box.
Definition at line 1534 of file qmessagebox.cpp.
QList< QAbstractButton * > QMessageBox::buttons | ( | ) | const |
Returns a list of all the buttons that have been added to the message box.
Definition at line 1517 of file qmessagebox.cpp.
Referenced by QMessageBoxPrivate::detectEscapeButton(), and keyPressEvent().
QString QMessageBox::buttonText | ( | int | button | ) | const |
Returns the text of the message box button button, or an empty string if the message box does not contain the button.
Use button() and QPushButton::text() instead.
Definition at line 2484 of file qmessagebox.cpp.
|
protectedvirtual |
Reimplemented Function
Reimplemented from QWidget.
Definition at line 1375 of file qmessagebox.cpp.
QAbstractButton * QMessageBox::clickedButton | ( | ) | const |
Returns the button that was clicked by the user, or 0 if the user hit the Esc key and no escape button was set.
If exec() hasn't been called yet, returns 0.
Example:
Definition at line 1096 of file qmessagebox.cpp.
Referenced by showNewMessageBox().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QDialog.
Definition at line 1360 of file qmessagebox.cpp.
|
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. 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 Default and Escape Keys {escape button} is returned.
The message box is an application modal dialog box.
Definition at line 1745 of file qmessagebox.cpp.
|
static |
Opens a critical message box with the given title and text.
The dialog may have up to three buttons. Each of the button parameters, button0, button1 and button2 may be set to one of the following values:
If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.
One button can be OR-ed with QMessageBox::Default, and one button can be OR-ed with QMessageBox::Escape.
Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked.
The message box is an application modal dialog box.
Definition at line 2423 of file qmessagebox.cpp.
|
static |
Displays a critical error message box with the given title and text, as well as one, two, or three buttons.
button0Text is the text of the first button, and is optional. If button0Text is not supplied, "OK" (translated) will be used. button1Text is the text of the second button, and is optional, and button2Text is the text of the third button, and is optional. defaultButtonNumber (0, 1 or 2) is the index of the default button; pressing Return or Enter is the same as clicking the default button. It defaults to 0 (the first button). escapeButtonNumber is the index of the Escape button; pressing Escape is the same as clicking this button. It defaults to -1; supply 0, 1, or 2 to make pressing Escape equivalent to clicking the relevant button.
The message box is an application modal dialog box.
Definition at line 2462 of file qmessagebox.cpp.
|
inlinestatic |
Definition at line 272 of file qmessagebox.h.
QPushButton * QMessageBox::defaultButton | ( | ) | const |
Returns the button that should be the message box's default button.
Returns 0 if no default button was set.
Definition at line 1114 of file qmessagebox.cpp.
Referenced by setWindowModality(), and showNewMessageBox().
QString QMessageBox::detailedText | ( | ) | const |
Referenced by setButtonText().
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.
Definition at line 993 of file qmessagebox.cpp.
Referenced by QMessageBoxPrivate::detectEscapeButton().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QDialog.
Definition at line 1315 of file qmessagebox.cpp.
|
slot |
Shows the message box as a modal dialog, blocking until the user closes it.
When using a QMessageBox with standard buttons, this functions returns a StandardButton value indicating the standard button that was clicked. When using QMessageBox with custom buttons, this function returns an opaque value; use clickedButton() to determine which button was clicked.
Users cannot 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.
Referenced by about(), aboutQt(), showNewMessageBox(), and QMessageBoxPrivate::showOldMessageBox().
Icon QMessageBox::icon | ( | ) | const |
Referenced by about(), setIcon(), setText(), and setWindowModality().
|
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. 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 Default and Escape Keys {escape button} is returned.
The message box is an application modal dialog box.
Definition at line 1638 of file qmessagebox.cpp.
Referenced by critical(), QFileSystemModel::setData(), and QCoreFuriCuri::timerEvent().
|
static |
Opens an information message box with the given title and the text.
The dialog may have up to three buttons. Each of the buttons, button0, button1 and button2 may be set to one of the following values:
If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.
One button can be OR-ed with QMessageBox::Default, and one button can be OR-ed with QMessageBox::Escape.
Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked.
The message box is an application modal dialog box.
Definition at line 2147 of file qmessagebox.cpp.
|
static |
Displays an information message box with the given title and text, as well as one, two or three buttons.
button0Text is the text of the first button, and is optional. If button0Text is not supplied, "OK" (translated) will be used. button1Text is the text of the second button, and is optional. button2Text is the text of the third button, and is optional. defaultButtonNumber (0, 1 or 2) is the index of the default button; pressing Return or Enter is the same as clicking the default button. It defaults to 0 (the first button). escapeButtonNumber is the index of the escape button; pressing Esc is the same as clicking this button. It defaults to -1; supply 0, 1 or 2 to make pressing Esc equivalent to clicking the relevant button.
The message box is an application modal dialog box.
Definition at line 2187 of file qmessagebox.cpp.
|
inlinestatic |
Definition at line 227 of file qmessagebox.h.
QString QMessageBox::informativeText | ( | ) | const |
Referenced by setDetailedText().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QDialog.
Definition at line 1408 of file qmessagebox.cpp.
void QMessageBox::open | ( | QObject * | receiver, |
const char * | member | ||
) |
Opens the dialog and connects its finished() or buttonClicked() signal to the slot specified by receiver and member.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
Definition at line 1495 of file qmessagebox.cpp.
|
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. 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 Default and Escape Keys {escape button} is returned.
The message box is an application modal dialog box.
Definition at line 1675 of file qmessagebox.cpp.
Referenced by QUnixPrintWidgetPrivate::checkFields().
|
static |
Opens a question message box with the given title and text.
The dialog may have up to three buttons. Each of the buttons, button0, button1 and button2 may be set to one of the following values:
If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.
One button can be OR-ed with QMessageBox::Default, and one button can be OR-ed with QMessageBox::Escape.
Returns the identity (QMessageBox::Yes, or QMessageBox::No, etc.) of the button that was clicked.
The message box is an application modal dialog box.
Definition at line 2239 of file qmessagebox.cpp.
|
static |
Displays a question message box with the given title and text, as well as one, two or three buttons.
button0Text is the text of the first button, and is optional. If button0Text is not supplied, "OK" (translated) will be used. button1Text is the text of the second button, and is optional. button2Text is the text of the third button, and is optional. defaultButtonNumber (0, 1 or 2) is the index of the default button; pressing Return or Enter is the same as clicking the default button. It defaults to 0 (the first button). escapeButtonNumber is the index of the Escape button; pressing Escape is the same as clicking this button. It defaults to -1; supply 0, 1 or 2 to make pressing Escape equivalent to clicking the relevant button.
The message box is an application modal dialog box.
Definition at line 2278 of file qmessagebox.cpp.
|
inlinestatic |
Definition at line 242 of file qmessagebox.h.
void QMessageBox::removeButton | ( | QAbstractButton * | button | ) |
Removes button from the button box without deleting it.
Definition at line 890 of file qmessagebox.cpp.
Referenced by addButton(), and setDetailedText().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QDialog.
Definition at line 1352 of file qmessagebox.cpp.
void QMessageBox::setButtonText | ( | int | button, |
const QString & | text | ||
) |
Sets the text of the message box button button to text.
Setting the text of a button that is not in the message box is silently ignored.
Use addButton() instead.
Definition at line 2509 of file qmessagebox.cpp.
void QMessageBox::setDefaultButton | ( | QPushButton * | button | ) |
Sets the message box's default button to button.
Definition at line 1131 of file qmessagebox.cpp.
Referenced by aboutQt(), setDefaultButton(), setWindowModality(), showNewMessageBox(), and QMessageBoxPrivate::showOldMessageBox().
void QMessageBox::setDefaultButton | ( | QMessageBox::StandardButton | button | ) |
Sets the message box's default button to button.
Definition at line 1152 of file qmessagebox.cpp.
void QMessageBox::setDetailedText | ( | const QString & | text | ) |
Definition at line 2541 of file qmessagebox.cpp.
void QMessageBox::setEscapeButton | ( | QAbstractButton * | button | ) |
Sets the button that gets activated when the Escape key is pressed to button.
Definition at line 1010 of file qmessagebox.cpp.
Referenced by setEscapeButton(), and QMessageBoxPrivate::showOldMessageBox().
void QMessageBox::setEscapeButton | ( | QMessageBox::StandardButton | button | ) |
Sets the buttons that gets activated when the Escape key is pressed to button.
Definition at line 1028 of file qmessagebox.cpp.
void QMessageBox::setIcon | ( | Icon | icon | ) |
Definition at line 1245 of file qmessagebox.cpp.
Referenced by changeEvent(), QMessageBox(), and setWindowModality().
void QMessageBox::setIconPixmap | ( | const QPixmap & | pixmap | ) |
Definition at line 1276 of file qmessagebox.cpp.
Referenced by about(), aboutQt(), and setIcon().
void QMessageBox::setInformativeText | ( | const QString & | text | ) |
Definition at line 2592 of file qmessagebox.cpp.
Referenced by aboutQt().
void QMessageBox::setStandardButtons | ( | StandardButtons | buttons | ) |
Definition at line 916 of file qmessagebox.cpp.
Referenced by QMessageBox().
void QMessageBox::setText | ( | const QString & | text | ) |
Definition at line 1180 of file qmessagebox.cpp.
Referenced by aboutQt().
void QMessageBox::setTextFormat | ( | Qt::TextFormat | format | ) |
Definition at line 1303 of file qmessagebox.cpp.
|
virtual |
Reimplemented Function
Reimplemented from QDialog.
Definition at line 1472 of file qmessagebox.cpp.
void QMessageBox::setWindowModality | ( | Qt::WindowModality | windowModality | ) |
This function shadows QWidget::setWindowModality().
Sets the modality of the message box to windowModality.
On Mac OS X, if the modality is set to Qt::WindowModal and the message box has a parent, then the message box will be a Qt::Sheet, otherwise the message box will be a standard dialog.
Definition at line 2687 of file qmessagebox.cpp.
void QMessageBox::setWindowTitle | ( | const QString & | title | ) |
This function shadows QWidget::setWindowTitle().
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).
Definition at line 2662 of file qmessagebox.cpp.
Referenced by aboutQt().
|
protectedvirtual |
Reimplemented Function
Reimplemented from QDialog.
Definition at line 1543 of file qmessagebox.cpp.
|
virtual |
Reimplemented from QDialog.
Definition at line 1905 of file qmessagebox.cpp.
QMessageBox::StandardButton QMessageBox::standardButton | ( | QAbstractButton * | button | ) | const |
Returns the standard button enum value corresponding to the given button, or NoButton if the given button isn't a standard button.
Definition at line 947 of file qmessagebox.cpp.
Referenced by showNewMessageBox().
StandardButtons QMessageBox::standardButtons | ( | ) | const |
Referenced by setStandardButtons().
Returns the pixmap used for a standard icon.
This allows the pixmaps to be used in more complex message boxes. icon specifies the required icon, e.g. QMessageBox::Question, QMessageBox::Information, QMessageBox::Warning or QMessageBox::Critical.
Call QStyle::standardIcon() with QStyle::SP_MessageBoxInformation etc. instead.
Definition at line 2844 of file qmessagebox.cpp.
Referenced by QErrorMessage::QErrorMessage(), and setWindowModality().
QString QMessageBox::text | ( | ) | const |
Referenced by about(), setDefaultButton(), and setWindowModality().
Qt::TextFormat QMessageBox::textFormat | ( | ) | const |
Referenced by setIconPixmap().
|
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. 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 Default and Escape Keys {escape button} is returned.
The message box is an application modal dialog box.
Definition at line 1710 of file qmessagebox.cpp.
Referenced by QFileDialogPrivate::_q_deleteCurrent(), QFileDialogPrivate::_q_goToDirectory(), QPrintDialogPrivate::_q_okClicked(), QFileDialog::accept(), QUnixPrintWidgetPrivate::checkFields(), and QPrintDialogPrivate::openWindowsPrintDialogModally().
|
static |
Opens a warning message box with the given title and text.
The dialog may have up to three buttons. Each of the button parameters, button0, button1 and button2 may be set to one of the following values:
If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.
One button can be OR-ed with QMessageBox::Default, and one button can be OR-ed with QMessageBox::Escape.
Returns the identity (QMessageBox::Ok or QMessageBox::No or ...) of the button that was clicked.
The message box is an application modal dialog box.
Definition at line 2331 of file qmessagebox.cpp.
|
static |
Displays a warning message box with the given title and text, as well as one, two, or three buttons.
button0Text is the text of the first button, and is optional. If button0Text is not supplied, "OK" (translated) will be used. button1Text is the text of the second button, and is optional, and button2Text is the text of the third button, and is optional. defaultButtonNumber (0, 1 or 2) is the index of the default button; pressing Return or Enter is the same as clicking the default button. It defaults to 0 (the first button). escapeButtonNumber is the index of the Escape button; pressing Escape is the same as clicking this button. It defaults to -1; supply 0, 1, or 2 to make pressing Escape equivalent to clicking the relevant button.
The message box is an application modal dialog box.
Definition at line 2370 of file qmessagebox.cpp.
|
inlinestatic |
Definition at line 257 of file qmessagebox.h.
|
private |
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.
Definition at line 71 of file qmessagebox.h.
|
private |
the message box's icon
The icon of the message box can be specified with one of the values:
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.
Definition at line 66 of file qmessagebox.h.
|
private |
the current icon
The icon currently used by the message box. Note that it's often hard to draw one pixmap that looks appropriate in all GUI styles; you may want to supply a different pixmap for each platform.
By default, this property is undefined.
Definition at line 67 of file qmessagebox.h.
|
private |
the informative text that provides a fuller description for the message
Infromative 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.
By default, this property contains an empty string.
Definition at line 73 of file qmessagebox.h.
|
private |
collection of standard buttons in the message box
This property controls which standard buttons are used by the message box.
By default, this property contains no standard buttons.
Definition at line 69 of file qmessagebox.h.
|
private |
the message box text to be displayed.
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, i.e., the message box will try to auto-detect the format of the text.
The default value of this property is an empty string.
Definition at line 64 of file qmessagebox.h.
Referenced by about().
|
private |
the format of the text displayed by the message box
The current text format used by the message box. See the Qt::TextFormat enum for an explanation of the possible options.
The default format is Qt::AutoText.
Definition at line 68 of file qmessagebox.h.