com.trolltech.qt.gui
Class QMessageBox

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by com.trolltech.qt.gui.QDialog
                      extended by com.trolltech.qt.gui.QMessageBox
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QMessageBox
extends QDialog

The QMessageBox class provides a modal dialog with a short message, an icon, and buttons laid out depending on the current style.

Message boxes are used to provide informative messages and to ask simple questions.

Basic Usage

The easiest way to pop up a message box in Qt is to call one of the static functions QMessageBox::information(), QMessageBox::question(), QMessageBox::critical(), and QMessageBox::warning(). For example:

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

Buttons are specified by combining StandardButtons using the bitwise OR operator. The order of the buttons on screen is platform-dependent. For example, on Windows, Save is displayed to the left of Cancel, whereas on Mac OS, the order is reversed.

The text part of all message box messages can be either rich text or plain text. With certain strings that contain XML meta characters, the auto-rich text detection may fail, interpreting plain text 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 explicitly with setTextFormat.

Note that the Microsoft Windows User Interface Guidelines recommend using the application name as the window's title.

The Standard Dialogs example shows how to use QMessageBox as well as other built-in Qt dialogs.

Severity Levels

QMessageBox supports four severity levels, indicated by an icon:

QuestionFor message boxes that ask a question as part of normal operation. Some style guides recommend using Information for this purpose.

InformationFor message boxes that are part of normal operation.

WarningFor message boxes that tell the user about unusual errors.

CriticalFor message boxes that tell the user about critical errors.

Advanced Usage

If the convenience static functions, such as QMessageBox::information() and QMessageBox::warning(), are not flexible enough for your needs, you can instantiate a QMessageBox on the stack. You can then use addButton to add buttons with standard or arbitrary text.

When using an instance of QMessageBox with standard buttons, you can test the return value of exec to determine which button was clicked. For example,

    QMessageBox msgBox;
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    switch (msgBox.exec()) {
    case QMessageBox::Yes:
        // yes was clicked
        break;
    case QMessageBox::No:
        // no was clicked
        break;
    default:
        // should never be reached
        break;
    }

When using an instance of QMessageBox with custom buttons, you can test the value of clickedButton after calling exec. For example,

    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
    }

In the example above, the Connect button is created using the addButton overload that takes a text and a ButtonRole. The ButtonRole is used by QMessageBox to determine the ordering of the buttons on screen (which varies according to the platform).

The text, icon and iconPixmap functions provide access to the current text and pixmap of the message box. The setText, setIcon and setIconPixmap let you change it. The difference between setIcon and setIconPixmap is that the former accepts a QMessageBox::Icon and can be used to set standard icons, whereas the latter accepts a QPixmap and can be used to set custom icons.

setButtonText() and buttonText() provide access to the buttons.

Default and Escape Keys

The default button (i.e., the button that is activated when the user presses Enter) can be specified using setDefaultButton. If none is specified, QMessageBox will try to find one automatically based on the ButtonRoles of the buttons in the dialog.

Similarly, the escape button (the button that is activated when the user presses Esc) is specified using setEscapeButton. If no escape button is specified, 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:
QDialogButtonBox, GUI Design Handbook: Message Box, Dialogs Example, Application Example

Nested Class Summary
static class QMessageBox.ButtonRole
          This enum describes the roles that can be used to describe buttons in the button box.
static class QMessageBox.Icon
          This enum has the following values.
static class QMessageBox.StandardButton
          These enums describe flags for standard buttons.
static class QMessageBox.StandardButtons
          This QFlag class provides flags for the int enum.
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QDialog
QDialog.DialogCode
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 
Fields inherited from class com.trolltech.qt.gui.QDialog
accepted, finished, rejected
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QMessageBox()
          Equivalent to QMessageBox(0).
QMessageBox(QMessageBox.Icon icon, java.lang.String title, java.lang.String text)
          Equivalent to QMessageBox(icon, title, text, NoButton, 0, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint).
QMessageBox(QMessageBox.Icon icon, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons)
          Equivalent to QMessageBox(icon, title, text, buttons, 0, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint).
QMessageBox(QMessageBox.Icon icon, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons, QWidget parent)
          Equivalent to QMessageBox(icon, title, text, buttons, parent, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint).
QMessageBox(QMessageBox.Icon icon, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons, QWidget parent, Qt.WindowFlags f)
          Constructs a message box with the given icon, title, text, and standard buttons.
QMessageBox(QWidget parent)
          Constructs a message box with no text and no buttons.
 
Method Summary
static void about(QWidget parent, java.lang.String title, java.lang.String text)
          Displays a simple about box with title title and text text.
static void aboutQt(QWidget parent)
          Equivalent to aboutQt(parent, QString()).
static void aboutQt(QWidget parent, java.lang.String title)
          Displays a simple message box about Qt, with the given title and centered over parent (if parent is not 0).
 void addButton(QAbstractButton button, QMessageBox.ButtonRole role)
          Adds the given button to the message box with the specified role.
 QPushButton addButton(QMessageBox.StandardButton button)
          Adds a standard button to the message box if it is valid to do so, and returns the push button.
 QPushButton addButton(java.lang.String text, QMessageBox.ButtonRole role)
          Creates a button with the given text, adds it to the message box for the specified role, and returns it.
 QAbstractButton button(QMessageBox.StandardButton which)
          Returns a pointer corresponding to the standard button which, or 0 if the standard button doesn't exist in this message box.
protected  void changeEvent(QEvent event)
          This function is reimplemented for internal reasons.
 QAbstractButton clickedButton()
          Returns the button that was clicked by the user, or 0 if the user hit the Esc key and no escape button was set.
protected  void closeEvent(QCloseEvent event)
          This function is reimplemented for internal reasons.
static QMessageBox.StandardButton critical(QWidget parent, java.lang.String title, java.lang.String text)
          Equivalent to critical(parent, title, text, Ok, NoButton).
static int critical(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButton button0, QMessageBox.StandardButton button1)
          This method is used internally by Qt Jambi.
static QMessageBox.StandardButton critical(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons)
          Equivalent to critical(parent, title, text, buttons, NoButton).
static QMessageBox.StandardButton critical(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons, QMessageBox.StandardButton defaultButton)
          Opens a critical message box with the title title and the text text.
 QPushButton defaultButton()
          Returns the button that should be the message box's default button.
 java.lang.String detailedText()
          Returns the text to be displayed in the details area..
 QAbstractButton escapeButton()
          Returns the button that is activated when escape is pressed.
 boolean event(QEvent e)
          This function is reimplemented for internal reasons.
static QMessageBox fromNativePointer(QNativePointer nativePointer)
          This function returns the QMessageBox instance pointed to by nativePointer
 QMessageBox.Icon icon()
          Returns the message box's icon.
 QPixmap iconPixmap()
          Returns the current icon.
static QMessageBox.StandardButton information(QWidget parent, java.lang.String title, java.lang.String text)
          Equivalent to information(parent, title, text, Ok, NoButton).
static QMessageBox.StandardButton information(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButton button0)
          Equivalent to information(parent, title, text, button0, NoButton).
static QMessageBox.StandardButton information(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButton button0, QMessageBox.StandardButton button1)
          This method is used internally by Qt Jambi.
static QMessageBox.StandardButton information(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons)
          Equivalent to information(parent, title, text, buttons, NoButton).
static QMessageBox.StandardButton information(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons, QMessageBox.StandardButton defaultButton)
          Opens an information message box with the title title and the text text.
 java.lang.String informativeText()
          Returns the informative text that provides a fuller description for the message.
protected  void keyPressEvent(QKeyEvent event)
          This function is reimplemented for internal reasons.
static QMessageBox.StandardButton question(QWidget parent, java.lang.String title, java.lang.String text)
          Equivalent to question(parent, title, text, Ok, NoButton).
static int question(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButton button0, QMessageBox.StandardButton button1)
          This method is used internally by Qt Jambi.
static QMessageBox.StandardButton question(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons)
          Equivalent to question(parent, title, text, buttons, NoButton).
static QMessageBox.StandardButton question(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons, QMessageBox.StandardButton defaultButton)
          Opens a question message box with the title title and the text text.
 void removeButton(QAbstractButton button)
          Removes button from the button box without deleting it.
protected  void resizeEvent(QResizeEvent event)
          This function is reimplemented for internal reasons.
 void setDefaultButton(QMessageBox.StandardButton button)
          Sets the message box's default button to button.
 void setDefaultButton(QPushButton button)
          Sets the message box's default button to button.
 void setDetailedText(java.lang.String text)
          Sets the text to be displayed in the details area.
 void setEscapeButton(QAbstractButton button)
          Sets the button that gets activated when the Escape key is pressed to button.
 void setEscapeButton(QMessageBox.StandardButton button)
          Sets the buttons that gets activated when the Escape key is pressed to button.
 void setIcon(QMessageBox.Icon arg__1)
          Sets the message box's icon to arg__1.
 void setIconPixmap(QPixmap pixmap)
          Sets the current icon to pixmap.
 void setInformativeText(java.lang.String text)
          Sets the informative text that provides a fuller description for the message to text.
 void setStandardButtons(QMessageBox.StandardButton... buttons)
          Sets collection of standard buttons in the message box to buttons.
 void setStandardButtons(QMessageBox.StandardButtons buttons)
          Sets collection of standard buttons in the message box to buttons.
 void setText(java.lang.String text)
          Sets the message box text to be displayed.
 void setTextFormat(Qt.TextFormat format)
          Sets the format of the text displayed by the message box to format.
protected  void showEvent(QShowEvent event)
          This function is reimplemented for internal reasons.
 QSize sizeHint()
          This function is reimplemented for internal reasons.
 QMessageBox.StandardButton standardButton(QAbstractButton button)
          Returns the standard button enum value corresponding to the given button, or NoButton if the given button isn't a standard button.
 QMessageBox.StandardButtons standardButtons()
          Returns collection of standard buttons in the message box.
 java.lang.String text()
          Returns the message box text to be displayed..
 Qt.TextFormat textFormat()
          Returns the format of the text displayed by the message box.
static QMessageBox.StandardButton warning(QWidget parent, java.lang.String title, java.lang.String text)
          Equivalent to warning(parent, title, text, Ok, NoButton).
static int warning(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButton button0, QMessageBox.StandardButton button1)
          This method is used internally by Qt Jambi.
static QMessageBox.StandardButton warning(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons)
          Equivalent to warning(parent, title, text, buttons, NoButton).
static QMessageBox.StandardButton warning(QWidget parent, java.lang.String title, java.lang.String text, QMessageBox.StandardButtons buttons, QMessageBox.StandardButton defaultButton)
          Opens a warning message box with the title title and the text text.
 
Methods inherited from class com.trolltech.qt.gui.QDialog
accept, adjustPosition, contextMenuEvent, done, eventFilter, exec, isSizeGripEnabled, minimumSizeHint, reject, result, setModal, setResult, setSizeGripEnabled, setVisible
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, contentsRect, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyReleaseEvent, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setWhatsThis, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QMessageBox

public QMessageBox()

Equivalent to QMessageBox(0).


QMessageBox

public QMessageBox(QWidget parent)

Constructs a message box with no text and no buttons.

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

The parent argument is passed to the QDialog constructor.


QMessageBox

public QMessageBox(QMessageBox.Icon icon,
                   java.lang.String title,
                   java.lang.String text,
                   QMessageBox.StandardButtons buttons,
                   QWidget parent)

Equivalent to QMessageBox(icon, title, text, buttons, parent, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint).


QMessageBox

public QMessageBox(QMessageBox.Icon icon,
                   java.lang.String title,
                   java.lang.String text,
                   QMessageBox.StandardButtons buttons)

Equivalent to QMessageBox(icon, title, text, buttons, 0, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint).


QMessageBox

public QMessageBox(QMessageBox.Icon icon,
                   java.lang.String title,
                   java.lang.String text)

Equivalent to QMessageBox(icon, title, text, NoButton, 0, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint).


QMessageBox

public QMessageBox(QMessageBox.Icon icon,
                   java.lang.String title,
                   java.lang.String text,
                   QMessageBox.StandardButtons buttons,
                   QWidget parent,
                   Qt.WindowFlags f)

Constructs a message box with the given icon, title, text, and standard buttons. (Buttons can also be added at any time using addButton.)

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

The parent and f arguments are passed to the QDialog constructor.

See Also:
setWindowTitle, setText, setIcon, setStandardButtons
Method Detail

addButton

public final QPushButton addButton(QMessageBox.StandardButton button)

Adds a standard button to the message box if it is valid to do so, and returns the push button.

See Also:
setStandardButtons

addButton

public final void addButton(QAbstractButton button,
                            QMessageBox.ButtonRole role)

Adds the given button to the message box with the specified role.

See Also:
removeButton, button, setStandardButtons

addButton

public final QPushButton addButton(java.lang.String text,
                                   QMessageBox.ButtonRole role)

Creates a button with the given text, adds it to the message box for the specified role, and returns it.


button

public final QAbstractButton button(QMessageBox.StandardButton which)

Returns a pointer corresponding to the standard button which, or 0 if the standard button doesn't exist in this message box.

See Also:
standardButtons, standardButton

clickedButton

public final QAbstractButton clickedButton()

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:

    QMessageBox messageBox(this);
    QAbstractButton *disconnectButton =
          messageBox.addButton(tr("Disconnect"), QMessageBox::ActionRole);
    ...
    messageBox.exec();
    if (messageBox.clickedButton() == disconnectButton) {
        ...
    }

See Also:
standardButton, button

defaultButton

public final QPushButton defaultButton()

Returns the button that should be the message box's default button. Returns 0 if no default button was set.

See Also:
setDefaultButton, addButton, QPushButton::setDefault

detailedText

public final java.lang.String detailedText()

Returns the text to be displayed in the details area..

The text will be interpreted as a plain text. The default value of this property is an empty string.

See Also:
setDetailedText

escapeButton

public final QAbstractButton escapeButton()

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

icon

public final QMessageBox.Icon icon()

Returns the message box's icon.

The icon of the message box can be one of the following predefined icons:

The actual pixmap used for displaying the icon depends on the current GUI style. You can also set a custom pixmap icon using the QMessageBox::iconPixmap property. The default icon is QMessageBox::NoIcon.

See Also:
setIcon, iconPixmap

iconPixmap

public final QPixmap iconPixmap()

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

See Also:
setIconPixmap, icon

informativeText

public final java.lang.String informativeText()

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

See Also:
setInformativeText

removeButton

public final void removeButton(QAbstractButton button)

Removes button from the button box without deleting it.

See Also:
addButton, setStandardButtons

setDefaultButton

public final void setDefaultButton(QPushButton button)

Sets the message box's default button to button.

See Also:
defaultButton, addButton, QPushButton::setDefault

setDefaultButton

public final void setDefaultButton(QMessageBox.StandardButton button)

Sets the message box's default button to button.

See Also:
addButton, QPushButton::setDefault

setDetailedText

public final void setDetailedText(java.lang.String text)

Sets the text to be displayed in the details area. to text.

The text will be interpreted as a plain text. The default value of this property is an empty string.

See Also:
detailedText

setEscapeButton

public final void setEscapeButton(QMessageBox.StandardButton button)

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

See Also:
escapeButton, addButton, clickedButton

setEscapeButton

public final void setEscapeButton(QAbstractButton button)

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

See Also:
addButton, clickedButton

setIcon

public final void setIcon(QMessageBox.Icon arg__1)

Sets the message box's icon to arg__1.

The icon of the message box can be one of the following predefined icons:

The actual pixmap used for displaying the icon depends on the current GUI style. You can also set a custom pixmap icon using the QMessageBox::iconPixmap property. The default icon is QMessageBox::NoIcon.

See Also:
iconPixmap

setIconPixmap

public final void setIconPixmap(QPixmap pixmap)

Sets the current icon to pixmap.

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.

See Also:
iconPixmap, icon

setInformativeText

public final void setInformativeText(java.lang.String text)

Sets the informative text that provides a fuller description for the message to text.

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.

See Also:
informativeText

setStandardButtons

public final void setStandardButtons(QMessageBox.StandardButton... buttons)

Sets collection of standard buttons in the message box to buttons.

This property controls which standard buttons are used by the message box.

See Also:
standardButtons, addButton

setStandardButtons

public final void setStandardButtons(QMessageBox.StandardButtons buttons)

Sets collection of standard buttons in the message box to buttons.

This property controls which standard buttons are used by the message box.

See Also:
standardButtons, addButton

setText

public final void setText(java.lang.String text)

Sets the message box text to be displayed. to text.

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.

See Also:
textFormat

setTextFormat

public final void setTextFormat(Qt.TextFormat format)

Sets the format of the text displayed by the message box to format.

The current text format used by the message box. See the Qt::TextFormat enum for an explanation of the possible options.

The default format is Qt::AutoText.

See Also:
textFormat, setText

standardButton

public final QMessageBox.StandardButton standardButton(QAbstractButton button)

Returns the standard button enum value corresponding to the given button, or NoButton if the given button isn't a standard button.

See Also:
button, standardButtons

standardButtons

public final QMessageBox.StandardButtons standardButtons()

Returns collection of standard buttons in the message box.

This property controls which standard buttons are used by the message box.

See Also:
setStandardButtons, addButton

text

public final java.lang.String text()

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

See Also:
setText, textFormat

textFormat

public final Qt.TextFormat textFormat()

Returns the format of the text displayed by the message box.

The current text format used by the message box. See the Qt::TextFormat enum for an explanation of the possible options.

The default format is Qt::AutoText.

See Also:
setTextFormat, setText

changeEvent

protected void changeEvent(QEvent event)

This function is reimplemented for internal reasons.

Overrides:
changeEvent in class QWidget

closeEvent

protected void closeEvent(QCloseEvent event)

This function is reimplemented for internal reasons.

Overrides:
closeEvent in class QDialog
See Also:
event, hide, close, QCloseEvent, Application Example

event

public boolean event(QEvent e)

This function is reimplemented for internal reasons.

Overrides:
event in class QWidget
See Also:
closeEvent, focusInEvent, focusOutEvent, enterEvent, keyPressEvent, keyReleaseEvent, leaveEvent, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveEvent, paintEvent, resizeEvent, QObject::event, QObject::timerEvent

keyPressEvent

protected void keyPressEvent(QKeyEvent event)

This function is reimplemented for internal reasons.

Overrides:
keyPressEvent in class QDialog
See Also:
keyReleaseEvent, QKeyEvent::ignore, setFocusPolicy, focusInEvent, focusOutEvent, event, QKeyEvent, Tetrix Example

resizeEvent

protected void resizeEvent(QResizeEvent event)

This function is reimplemented for internal reasons.

Overrides:
resizeEvent in class QDialog
See Also:
moveEvent, event, resize, QResizeEvent, paintEvent, Example

showEvent

protected void showEvent(QShowEvent event)

This function is reimplemented for internal reasons.

Overrides:
showEvent in class QDialog
See Also:
visible, event, QShowEvent

sizeHint

public QSize sizeHint()

This function is reimplemented for internal reasons.

Overrides:
sizeHint in class QDialog
See Also:
QSize::isValid, minimumSizeHint, sizePolicy, setMinimumSize, updateGeometry

about

public static void about(QWidget parent,
                         java.lang.String title,
                         java.lang.String text)

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:

  1. It prefers parent->icon() if that 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.

The about box has a single button labelled "OK".

See Also:
QWidget::windowIcon, QApplication::activeWindow

aboutQt

public static void aboutQt(QWidget parent)

Equivalent to aboutQt(parent, QString()).


aboutQt

public static void aboutQt(QWidget parent,
                           java.lang.String title)

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.

See Also:
QApplication::aboutQt

critical

public static QMessageBox.StandardButton critical(QWidget parent,
                                                  java.lang.String title,
                                                  java.lang.String text,
                                                  QMessageBox.StandardButtons buttons)

Equivalent to critical(parent, title, text, buttons, NoButton).


critical

public static QMessageBox.StandardButton critical(QWidget parent,
                                                  java.lang.String title,
                                                  java.lang.String text)

Equivalent to critical(parent, title, text, Ok, NoButton).


critical

public static QMessageBox.StandardButton critical(QWidget parent,
                                                  java.lang.String title,
                                                  java.lang.String text,
                                                  QMessageBox.StandardButtons buttons,
                                                  QMessageBox.StandardButton defaultButton)

Opens a critical message box with the title title and the text text. The standard buttons buttons is added to the message box. defaultButton specifies the button be used as the defaultButton. If the defaultButton is set to QMessageBox::NoButton, QMessageBox picks a suitable default automatically.

Returns the identity of the standard button that was activated. If Esc was pressed, returns the escape button (if any).

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

See Also:
question, warning, information

critical

public static int critical(QWidget parent,
                           java.lang.String title,
                           java.lang.String text,
                           QMessageBox.StandardButton button0,
                           QMessageBox.StandardButton button1)

This method is used internally by Qt Jambi. Do not use it in your applications.


information

public static QMessageBox.StandardButton information(QWidget parent,
                                                     java.lang.String title,
                                                     java.lang.String text,
                                                     QMessageBox.StandardButton button0)

Equivalent to information(parent, title, text, button0, NoButton).


information

public static QMessageBox.StandardButton information(QWidget parent,
                                                     java.lang.String title,
                                                     java.lang.String text,
                                                     QMessageBox.StandardButton button0,
                                                     QMessageBox.StandardButton button1)

This method is used internally by Qt Jambi. Do not use it in your applications.


information

public static QMessageBox.StandardButton information(QWidget parent,
                                                     java.lang.String title,
                                                     java.lang.String text,
                                                     QMessageBox.StandardButtons buttons)

Equivalent to information(parent, title, text, buttons, NoButton).


information

public static QMessageBox.StandardButton information(QWidget parent,
                                                     java.lang.String title,
                                                     java.lang.String text)

Equivalent to information(parent, title, text, Ok, NoButton).


information

public static QMessageBox.StandardButton information(QWidget parent,
                                                     java.lang.String title,
                                                     java.lang.String text,
                                                     QMessageBox.StandardButtons buttons,
                                                     QMessageBox.StandardButton defaultButton)

Opens an information message box with the title title and the text text. The standard buttons buttons is added to the message box. defaultButton specifies the button be used as the defaultButton. If the defaultButton is set to QMessageBox::NoButton, QMessageBox picks a suitable default automatically.

Returns the identity of the standard button that was activated. If Esc was pressed, returns the escape button (if any).

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

See Also:
question, warning, critical

question

public static int question(QWidget parent,
                           java.lang.String title,
                           java.lang.String text,
                           QMessageBox.StandardButton button0,
                           QMessageBox.StandardButton button1)

This method is used internally by Qt Jambi. Do not use it in your applications.


question

public static QMessageBox.StandardButton question(QWidget parent,
                                                  java.lang.String title,
                                                  java.lang.String text,
                                                  QMessageBox.StandardButtons buttons)

Equivalent to question(parent, title, text, buttons, NoButton).


question

public static QMessageBox.StandardButton question(QWidget parent,
                                                  java.lang.String title,
                                                  java.lang.String text)

Equivalent to question(parent, title, text, Ok, NoButton).


question

public static QMessageBox.StandardButton question(QWidget parent,
                                                  java.lang.String title,
                                                  java.lang.String text,
                                                  QMessageBox.StandardButtons buttons,
                                                  QMessageBox.StandardButton defaultButton)

Opens a question message box with the title title and the text text. The standard buttons buttons is added to the message box. defaultButton specifies the button be used as the defaultButton. If the defaultButton is set to QMessageBox::NoButton, QMessageBox picks a suitable default automatically.

Returns the identity of the standard button that was activated. If Esc was pressed, returns the escape button (if any).

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

See Also:
information, warning, critical

warning

public static int warning(QWidget parent,
                          java.lang.String title,
                          java.lang.String text,
                          QMessageBox.StandardButton button0,
                          QMessageBox.StandardButton button1)

This method is used internally by Qt Jambi. Do not use it in your applications.


warning

public static QMessageBox.StandardButton warning(QWidget parent,
                                                 java.lang.String title,
                                                 java.lang.String text,
                                                 QMessageBox.StandardButtons buttons)

Equivalent to warning(parent, title, text, buttons, NoButton).


warning

public static QMessageBox.StandardButton warning(QWidget parent,
                                                 java.lang.String title,
                                                 java.lang.String text)

Equivalent to warning(parent, title, text, Ok, NoButton).


warning

public static QMessageBox.StandardButton warning(QWidget parent,
                                                 java.lang.String title,
                                                 java.lang.String text,
                                                 QMessageBox.StandardButtons buttons,
                                                 QMessageBox.StandardButton defaultButton)

Opens a warning message box with the title title and the text text. The standard buttons buttons is added to the message box. defaultButton specifies the button be used as the defaultButton. If the defaultButton is set to QMessageBox::NoButton, QMessageBox picks a suitable default automatically.

Returns the identity of the standard button that was activated. If Esc was pressed, returns the escape button (if any).

If parent is 0, the message box becomes an application-global modal dialog box. If parent is a widget, the message box becomes modal relative to parent.

See Also:
question, information, critical

fromNativePointer

public static QMessageBox fromNativePointer(QNativePointer nativePointer)
This function returns the QMessageBox instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.