#include <qmessagebox.h>
Inheritance diagram for QMessageBox:


Message boxes are used to provide informative messages and to ask simple questions.
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: @code 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); \endcode 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, \gui{Save} is displayed to the left of \gui{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 \l{dialogs/standarddialogs}{Standard Dialogs} example shows how to use QMessageBox as well as other built-in Qt dialogs. @section Severity Levels QMessageBox supports four severity levels, indicated by an icon: \table \row \o \img qmessagebox-quest.png \o \l Question \o For message boxes that ask a question as part of normal operation. Some style guides recommend using Information for this purpose. \row \o \img qmessagebox-info.png \o \l Information \o For message boxes that are part of normal operation. \row \o \img qmessagebox-warn.png \o \l Warning \o For message boxes that tell the user about unusual errors. \row \o \img qmessagebox-crit.png \o \l Critical \o For message boxes that tell the user about critical errors. \endtable @section 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, @code 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; } \endcode When using an instance of QMessageBox with custom buttons, you can test the value of clickedButton() after calling exec(). For example, @code 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 } \endcode In the example above, the \gui 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. @section Default and Escape Keys The default button (i.e., the button that is activated when the user presses \key Enter) can be specified using setDefaultButton(). If none is specified, QMessageBox will try to find one automatically based on the \l{ButtonRole}s of the buttons in the dialog. Similarly, the escape button (the button that is activated when the user presses \key Esc) is specified using setEscapeButton(). If no escape button is specified, QMessageBox attempts to automatically detect an escape button as follows: \list 1 \o If there is only one button, it is made the escape button. \o If there is a \l Cancel button, it is made the escape button. \o On Mac OS X only, if there is exactly one button with the role QMessageBox::RejectRole, it is made the escape button. \endlist When an escape button could not be automatically detected, pressing \key Esc has no effect. \sa QDialogButtonBox, {fowler}{GUI Design Handbook: Message Box}, {Standard Dialogs Example}, {Application Example} Definition at line 39 of file qmessagebox.h.
Public Types | |
| enum | Icon |
| enum | ButtonRole |
| enum | StandardButton |
| typedef StandardButton | Button |
Public Member Functions | |
| QMessageBox (QWidget *parent=0) | |
| QMessageBox (Icon icon, const QString &title, const QString &text, StandardButtons buttons=NoButton, QWidget *parent=0, Qt::WindowFlags f=Qt::Dialog|Qt::MSWindowsFixedSizeDialogHint) | |
| ~QMessageBox () | |
| void | addButton (QAbstractButton *button, ButtonRole role) |
| QPushButton * | addButton (const QString &text, ButtonRole role) |
| QPushButton * | addButton (StandardButton button) |
| void | removeButton (QAbstractButton *button) |
| void | setStandardButtons (StandardButtons buttons) |
| StandardButtons | standardButtons () const |
| StandardButton | standardButton (QAbstractButton *button) const |
| QAbstractButton * | button (StandardButton which) const |
| QPushButton * | defaultButton () const |
| void | setDefaultButton (QPushButton *button) |
| QAbstractButton * | escapeButton () const |
| void | setEscapeButton (QAbstractButton *button) |
| QAbstractButton * | clickedButton () const |
| QString | text () const |
| void | setText (const QString &text) |
| Icon | icon () const |
| void | setIcon (Icon) |
| QPixmap | iconPixmap () const |
| void | setIconPixmap (const QPixmap &pixmap) |
| Qt::TextFormat | textFormat () const |
| void | setTextFormat (Qt::TextFormat format) |
| QSize | sizeHint () const |
| 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) | |
| QString | buttonText (int button) const |
| void | setButtonText (int button, const QString &text) |
| QString | informativeText () const |
| void | setInformativeText (const QString &text) |
| QString | detailedText () const |
| void | setDetailedText (const QString &text) |
| void | setWindowTitle (const QString &title) |
| void | setWindowModality (Qt::WindowModality windowModality) |
Static Public Member Functions | |
| static StandardButton | information (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
| static StandardButton | question (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
| static StandardButton | warning (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
| static StandardButton | critical (QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton) |
| static void | about (QWidget *parent, const QString &title, const QString &text) |
| static void | aboutQt (QWidget *parent, const QString &title=QString()) |
| static int | information (QWidget *parent, const QString &title, const QString &text, int button0, int button1=0, int button2=0) |
| static int | information (QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text=QString(), const QString &button2Text=QString(), int defaultButtonNumber=0, int escapeButtonNumber=-1) |
| static StandardButton | information (QWidget *parent, const QString &title, const QString &text, StandardButton button0, StandardButton button1=NoButton) |
| static int | question (QWidget *parent, const QString &title, const QString &text, int button0, int button1=0, int button2=0) |
| static int | question (QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text=QString(), const QString &button2Text=QString(), int defaultButtonNumber=0, int escapeButtonNumber=-1) |
| static int | question (QWidget *parent, const QString &title, const QString &text, StandardButton button0, StandardButton button1) |
| static int | warning (QWidget *parent, const QString &title, const QString &text, int button0, int button1, int button2=0) |
| static int | warning (QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text=QString(), const QString &button2Text=QString(), int defaultButtonNumber=0, int escapeButtonNumber=-1) |
| static int | warning (QWidget *parent, const QString &title, const QString &text, StandardButton button0, StandardButton button1) |
| static int | critical (QWidget *parent, const QString &title, const QString &text, int button0, int button1, int button2=0) |
| static int | critical (QWidget *parent, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text=QString(), const QString &button2Text=QString(), int defaultButtonNumber=0, int escapeButtonNumber=-1) |
| static int | critical (QWidget *parent, const QString &title, const QString &text, StandardButton button0, StandardButton button1) |
| static QPixmap | standardIcon (Icon icon) |
Protected Member Functions | |
| void | resizeEvent (QResizeEvent *event) |
| void | showEvent (QShowEvent *event) |
| void | closeEvent (QCloseEvent *event) |
| void | keyPressEvent (QKeyEvent *event) |
| void | changeEvent (QEvent *event) |
Use QMessageBox::StandardButton instead.
Definition at line 113 of file qmessagebox.h.
| enum QMessageBox::Icon |
This enum has the following values:
NoIcon the message box does not have any icon.
Question an icon indicating that the message is asking a question.
Information an icon indicating that the message is nothing out of the ordinary.
Warning an icon indicating that the message is a warning, but can be dealt with.
Critical an icon indicating that the message represents a critical problem.
Definition at line 56 of file qmessagebox.h.
00056 { 00057 NoIcon = 0, 00058 Information = 1, 00059 Warning = 2, 00060 Critical = 3, 00061 Question = 4 00062 };
This enum describes the roles that can be used to describe buttons in the button box. Combinations of these roles are as flags used to describe different aspects of their behavior.
InvalidRole The button is invalid. AcceptRole Clicking the button causes the dialog to be accepted (e.g. OK). RejectRole Clicking the button causes the dialog to be rejected (e.g. Cancel). DestructiveRole Clicking the button causes a destructive change (e.g. for Discarding Changes). ActionRole Clicking the button causes changes to the elements in the dialog (e.g. reset all the values or read defaults). HelpRole The button can be clicked to request help. YesRole The button is a "Yes"-like button. NoRole The button is a "No"-like button. ApplyRole The button applies current changes. ResetRole The button resets the dialog's fields to default values.
NRoles
Definition at line 64 of file qmessagebox.h.
00064 { 00065 // keep this in sync with QDialogButtonBox::ButtonRole 00066 InvalidRole = -1, 00067 AcceptRole, 00068 RejectRole, 00069 DestructiveRole, 00070 ActionRole, 00071 HelpRole, 00072 YesRole, 00073 NoRole, 00074 ResetRole, 00075 ApplyRole, 00076 00077 NRoles 00078 };
Ok An "OK" button defined with the AcceptRole. Open A "Open" button defined with the AcceptRole. Save A "Save" button defined with the AcceptRole. Cancel A "Cancel" button defined with the RejectRole. Close A "Close" button defined with the RejectRole. Discard A "Discard" or "Don't Save" button, depending on the platform, defined with the DestructiveRole. Apply An "Apply" button defined with the ApplyRole. Reset A "Reset" button defined with the ResetRole. RestoreDefaults A "Restore Defaults" button defined with the ResetRole. Help A "Help" button defined with the HelpRole. SaveAll A "Save All" button defined with the AcceptRole. Yes A "Yes" button defined with the YesRole. YesToAll A "Yes to All" button defined with the YesRole. No A "No" button defined with the NoRole. NoToAll A "No to All" button defined with the NoRole. Abort An "Abort" button defined with the RejectRole. Retry A "Retry" button defined with the AcceptRole. Ignore An "Ignore" button defined with the AcceptRole.
NoButton An invalid button.
FirstButton LastButton
The following values are obsolete:
YesAll Use YesToAll instead. NoAll Use NoToAll instead. Default Use the defaultButton argument of information(), warning(), etc. instead, or call setDefaultButton(). Escape Call setEscapeButton() instead. FlagMask ButtonMask
Definition at line 80 of file qmessagebox.h.
00080 { 00081 // keep this in sync with QDialogButtonBox::StandardButton 00082 NoButton = 0x00000000, 00083 Ok = 0x00000400, 00084 Save = 0x00000800, 00085 SaveAll = 0x00001000, 00086 Open = 0x00002000, 00087 Yes = 0x00004000, 00088 YesToAll = 0x00008000, 00089 No = 0x00010000, 00090 NoToAll = 0x00020000, 00091 Abort = 0x00040000, 00092 Retry = 0x00080000, 00093 Ignore = 0x00100000, 00094 Close = 0x00200000, 00095 Cancel = 0x00400000, 00096 Discard = 0x00800000, 00097 Help = 0x01000000, 00098 Apply = 0x02000000, 00099 Reset = 0x04000000, 00100 RestoreDefaults = 0x08000000, 00101 00102 FirstButton = Ok, // internal 00103 LastButton = RestoreDefaults, // internal 00104 00105 YesAll = YesToAll, // obsolete 00106 NoAll = NoToAll, // obsolete 00107 00108 Default = 0x00000100, // obsolete 00109 Escape = 0x00000200, // obsolete 00110 FlagMask = 0x00000300, // obsolete 00111 ButtonMask = ~FlagMask // obsolete 00112 };
| QMessageBox::QMessageBox | ( | QWidget * | parent = 0 |
) | [explicit] |
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.
Definition at line 661 of file qmessagebox.cpp.
References d.
00662 : QDialog(*new QMessageBoxPrivate, parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint) 00663 { 00664 Q_D(QMessageBox); 00665 d->init(); 00666 }
| 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. (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.
Definition at line 681 of file qmessagebox.cpp.
References d, NoButton, setIcon(), setStandardButtons(), and text().
00683 : QDialog(*new QMessageBoxPrivate, parent, f | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint) 00684 { 00685 Q_D(QMessageBox); 00686 d->init(title, text); 00687 setIcon(icon); 00688 if (buttons != NoButton) 00689 setStandardButtons(buttons); 00690 }
Here is the call graph for this function:

| 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: QMessageBox::NoIcon QMessageBox::Question QMessageBox::Information QMessageBox::Warning QMessageBox::Critical
Each button, button0, button1 and button2, can have one of the following values: QMessageBox::NoButton QMessageBox::Ok QMessageBox::Cancel QMessageBox::Yes QMessageBox::No QMessageBox::Abort QMessageBox::Retry QMessageBox::Ignore QMessageBox::YesAll QMessageBox::NoAll
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 Escape is pressed).
snippets/dialogs/dialogs.cpp // hardware failure QMessageBox mb("Application Name", // try again
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.
Definition at line 1606 of file qmessagebox.cpp.
References d, setIcon(), and text().
01609 : QDialog(*new QMessageBoxPrivate, parent, 01610 f /*| Qt::MSWindowsFixedSizeDialogHint #### */| Qt::WindowTitleHint | Qt::WindowSystemMenuHint) 01611 { 01612 Q_D(QMessageBox); 01613 d->init(title, text); 01614 setIcon(icon); 01615 d->addOldButtons(button0, button1, button2); 01616 }
Here is the call graph for this function:

| void QMessageBox::addButton | ( | QAbstractButton * | button, | |
| ButtonRole | role | |||
| ) |
Definition at line 707 of file qmessagebox.cpp.
References button(), d, and removeButton().
Referenced by aboutQt(), addButton(), setButtonText(), showEvent(), showNewMessageBox(), QMessageBoxPrivate::showOldMessageBox(), and Dialog::warningMessage().
00708 { 00709 Q_D(QMessageBox); 00710 if (!button) 00711 return; 00712 removeButton(button); 00713 d->buttonBox->addButton(button, (QDialogButtonBox::ButtonRole)role); 00714 d->customButtonList.append(button); 00715 d->autoAddOkButton = false; 00716 }
Here is the call graph for this function:

| QPushButton * QMessageBox::addButton | ( | const QString & | text, | |
| ButtonRole | role | |||
| ) |
Definition at line 725 of file qmessagebox.cpp.
References addButton(), QDialog::QPushButton, and text().
00726 { 00727 QPushButton *pushButton = new QPushButton(text); 00728 addButton(pushButton, role); 00729 return pushButton; 00730 }
Here is the call graph for this function:

| QPushButton * QMessageBox::addButton | ( | StandardButton | button | ) |
Definition at line 741 of file qmessagebox.cpp.
References d.
00742 { 00743 Q_D(QMessageBox); 00744 QPushButton *pushButton = d->buttonBox->addButton((QDialogButtonBox::StandardButton)button); 00745 if (pushButton) 00746 d->autoAddOkButton = false; 00747 return pushButton; 00748 }
| void QMessageBox::removeButton | ( | QAbstractButton * | button | ) |
Definition at line 757 of file qmessagebox.cpp.
Referenced by addButton(), and setDetailedText().
00758 { 00759 Q_D(QMessageBox); 00760 d->customButtonList.removeAll(button); 00761 if (d->escapeButton == button) 00762 d->escapeButton = 0; 00763 if (d->defaultButton == button) 00764 d->defaultButton = 0; 00765 d->buttonBox->removeButton(button); 00766 }
Here is the call graph for this function:

| void QMessageBox::setStandardButtons | ( | StandardButtons | buttons | ) |
Definition at line 777 of file qmessagebox.cpp.
References QList< T >::contains(), and d.
Referenced by QMessageBox().
00778 { 00779 Q_D(QMessageBox); 00780 d->buttonBox->setStandardButtons(QDialogButtonBox::StandardButtons(int(buttons))); 00781 00782 QList<QAbstractButton *> buttonList = d->buttonBox->buttons(); 00783 if (!buttonList.contains(d->escapeButton)) 00784 d->escapeButton = 0; 00785 if (!buttonList.contains(d->defaultButton)) 00786 d->defaultButton = 0; 00787 d->autoAddOkButton = false; 00788 }
Here is the call graph for this function:

| QMessageBox::StandardButtons QMessageBox::standardButtons | ( | ) | const |
Definition at line 790 of file qmessagebox.cpp.
References d.
00791 { 00792 Q_D(const QMessageBox); 00793 return QMessageBox::StandardButtons(int(d->buttonBox->standardButtons())); 00794 }
| QMessageBox::StandardButton QMessageBox::standardButton | ( | QAbstractButton * | button | ) | const |
Definition at line 804 of file qmessagebox.cpp.
Referenced by showNewMessageBox().
00805 { 00806 Q_D(const QMessageBox); 00807 return (QMessageBox::StandardButton)d->buttonBox->standardButton(button); 00808 }
Here is the call graph for this function:

| QAbstractButton * QMessageBox::button | ( | StandardButton | which | ) | const |
Definition at line 818 of file qmessagebox.cpp.
References d.
Referenced by addButton(), removeButton(), setDefaultButton(), setEscapeButton(), and standardButton().
00819 { 00820 Q_D(const QMessageBox); 00821 return d->buttonBox->button(QDialogButtonBox::StandardButton(which)); 00822 }
| QPushButton * QMessageBox::defaultButton | ( | ) | const |
Definition at line 926 of file qmessagebox.cpp.
References d.
Referenced by showNewMessageBox().
00927 { 00928 Q_D(const QMessageBox); 00929 return d->defaultButton; 00930 }
| void QMessageBox::setDefaultButton | ( | QPushButton * | button | ) |
Definition at line 940 of file qmessagebox.cpp.
References button(), d, and QWidget::setFocus().
Referenced by showNewMessageBox(), and QMessageBoxPrivate::showOldMessageBox().
00941 { 00942 Q_D(QMessageBox); 00943 if (!d->buttonBox->buttons().contains(button)) 00944 return; 00945 d->defaultButton = button; 00946 button->setDefault(true); 00947 button->setFocus(); 00948 }
Here is the call graph for this function:

| QAbstractButton * QMessageBox::escapeButton | ( | ) | const |
Definition at line 832 of file qmessagebox.cpp.
References d.
00833 { 00834 Q_D(const QMessageBox); 00835 return d->escapeButton; 00836 }
| void QMessageBox::setEscapeButton | ( | QAbstractButton * | button | ) |
Definition at line 846 of file qmessagebox.cpp.
Referenced by QMessageBoxPrivate::showOldMessageBox().
00847 { 00848 Q_D(QMessageBox); 00849 if (d->buttonBox->buttons().contains(button)) 00850 d->escapeButton = button; 00851 }
Here is the call graph for this function:

| QAbstractButton * QMessageBox::clickedButton | ( | ) | const |
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) { ... }
Definition at line 911 of file qmessagebox.cpp.
References d.
Referenced by showNewMessageBox().
00912 { 00913 Q_D(const QMessageBox); 00914 return d->clickedButton; 00915 }
| QString QMessageBox::text | ( | ) | const |
Definition at line 963 of file qmessagebox.cpp.
References d.
Referenced by about(), addButton(), critical(), information(), QMessageBox(), question(), setButtonText(), setDetailedText(), setInformativeText(), setText(), and warning().
00964 { 00965 Q_D(const QMessageBox); 00966 return d->label->text(); 00967 }
| void QMessageBox::setText | ( | const QString & | text | ) |
Definition at line 969 of file qmessagebox.cpp.
References Qt::AutoText, d, Qt::mightBeRichText(), Qt::RichText, and text().
Referenced by TrWindow::about(), MainWindow::about(), aboutQt(), MainWindow::helpAbout(), and MainWindow::on_actionAboutApplication_triggered().
00970 { 00971 Q_D(QMessageBox); 00972 d->label->setText(text); 00973 d->label->setWordWrap(d->label->textFormat() == Qt::RichText 00974 || (d->label->textFormat() == Qt::AutoText && Qt::mightBeRichText(text))); 00975 d->updateSize(); 00976 }
Here is the call graph for this function:

| QMessageBox::Icon QMessageBox::icon | ( | ) | const |
Definition at line 1020 of file qmessagebox.cpp.
References d.
Referenced by about().
01021 { 01022 Q_D(const QMessageBox); 01023 return d->icon; 01024 }
| void QMessageBox::setIcon | ( | Icon | ) |
Definition at line 1026 of file qmessagebox.cpp.
References d, setIconPixmap(), and standardIcon().
Referenced by MainWindow::about(), TrWindow::about(), changeEvent(), MainWindow::helpAbout(), MainWindow::on_actionAboutApplication_triggered(), and QMessageBox().
01027 { 01028 Q_D(QMessageBox); 01029 setIconPixmap(QMessageBox::standardIcon((QMessageBox::Icon)icon)); 01030 d->icon = icon; 01031 }
Here is the call graph for this function:

| QPixmap QMessageBox::iconPixmap | ( | ) | const |
Definition at line 1043 of file qmessagebox.cpp.
References d.
01044 { 01045 Q_D(const QMessageBox); 01046 return *d->iconLabel->pixmap(); 01047 }
| void QMessageBox::setIconPixmap | ( | const QPixmap & | pixmap | ) |
| Qt::TextFormat QMessageBox::textFormat | ( | ) | const |
Definition at line 1068 of file qmessagebox.cpp.
References d.
01069 { 01070 Q_D(const QMessageBox); 01071 return d->label->textFormat(); 01072 }
| void QMessageBox::setTextFormat | ( | Qt::TextFormat | format | ) |
Definition at line 1074 of file qmessagebox.cpp.
References Qt::AutoText, d, Qt::mightBeRichText(), and Qt::RichText.
Referenced by TrWindow::about().
01075 { 01076 Q_D(QMessageBox); 01077 d->label->setTextFormat(format); 01078 d->label->setWordWrap(format == Qt::RichText 01079 || (format == Qt::AutoText && Qt::mightBeRichText(d->label->text()))); 01080 }
Here is the call graph for this function:

| QMessageBox::StandardButton QMessageBox::information | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| StandardButtons | buttons = Ok, |
|||
| StandardButton | defaultButton = NoButton | |||
| ) | [static] |
Returns the identity of the standard button that was activated. If Esc was pressed, returns the {Default and Escape Keys}{escape button}.
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.
Definition at line 1261 of file qmessagebox.cpp.
References Information, QObject::parent(), showNewMessageBox(), and text().
Referenced by SaveFormAsTemplate::accept(), Browser::Browser(), Window::closeEvent(), Q3DataManager::confirmCancel(), Q3DataManager::confirmEdit(), qdesigner_internal::QDesignerResource::create(), Client::displayError(), Dialog::displayError(), BlockingClient::displayError(), Q3FileDialog::done(), FtpWindow::downloadFile(), HttpWindow::downloadFile(), TsHandler::fatalError(), XbelHandler::fatalError(), QphHandler::fatalError(), FtpWindow::ftpCommandFinished(), Dialog::help(), HttpWindow::httpRequestFinished(), Dialog::informationMessage(), QDesigner::initialize(), main(), TrWindow::maybeSave(), Window::messageClicked(), QDesignerActions::notImplementedYet(), QSqlConnectionDialog::on_okButton_clicked(), ImageViewer::open(), qdesigner_internal::FormWindow::paste(), MainWindow::printImage(), XbelTree::read(), HttpWindow::readResponseHeader(), MainWindow::setCompleted(), HelpWindow::setSource(), KAsteroidsView::showEvent(), ChatDialog::showInformation(), Oubliette::showInstructions(), Oubliette::showVictory(), qdesigner_internal::ActionEditor::slotNotImplemented(), and BatchTranslationDialog::startTranslation().
01264 { 01265 return showNewMessageBox(parent, Information, title, text, buttons, 01266 defaultButton); 01267 }
Here is the call graph for this function:

| QMessageBox::StandardButton QMessageBox::question | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| StandardButtons | buttons = Ok, |
|||
| StandardButton | defaultButton = NoButton | |||
| ) | [static] |
Returns the identity of the standard button that was activated. If Esc was pressed, returns the {Default and Escape Keys}{escape button}.
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.
Definition at line 1288 of file qmessagebox.cpp.
References QObject::parent(), Question, showNewMessageBox(), and text().
Referenced by MainWindow::printImage(), Dialog::questionMessage(), Main::quit(), and QPrintDialogPrivate::setupPrinter().
01291 { 01292 return showNewMessageBox(parent, Question, title, text, buttons, defaultButton); 01293 }
Here is the call graph for this function:

| QMessageBox::StandardButton QMessageBox::warning | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| StandardButtons | buttons = Ok, |
|||
| StandardButton | defaultButton = NoButton | |||
| ) | [static] |
Returns the identity of the standard button that was activated. If Esc was pressed, returns the {Default and Escape Keys}{escape button}.
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.
Definition at line 1313 of file qmessagebox.cpp.
References QObject::parent(), showNewMessageBox(), text(), and Warning.
Referenced by QFileDialogPrivate::_q_deleteCurrent(), QFileDialogPrivate::_q_enterDirectory(), QFileDialog::accept(), qdesigner_internal::PromoteToCustomWidgetDialog::accept(), Browser::addConnection(), qdesigner_internal::EditableResourceModel::addFiles(), MainWindow::addTorrent(), HelpDialog::buildContentDict(), HelpDialog::buildKeywordDB(), QDBusViewer::callMethod(), Launcher::closeEvent(), qdesigner_internal::ConnectionModel::connectionChanged(), qdesigner_internal::QDesignerResource::create(), qdesigner_internal::QDesignerResource::createResources(), Q3FileDialog::deleteFile(), TrWindow::findAgain(), Q3DataManager::handleError(), Main::loadConfig(), Main::loadFeatures(), MainWindow::loadFile(), MdiChild::loadFile(), HelpDialog::loadIndexFile(), MainWindow::loadLayout(), MdiChild::maybeSave(), MainWindow::maybeSave(), TextEdit::maybeSave(), qdesigner_internal::ModelCache::model(), TrWindow::newPhraseBook(), TrWindow::openFile(), QDesignerActions::openForm(), MainWindow::openImage(), TrWindow::openPhraseBook(), TrWindow::previewForm(), QDesignerActions::readInForm(), TrWindow::release(), TrWindow::releaseAs(), TrWindow::save(), qdesigner_internal::QDesignerResource::save(), PhraseBookBox::save(), Main::saveConfig(), MdiChild::saveFile(), MainWindow::saveFile(), QDesignerActions::saveFormAs(), MainWindow::saveLayout(), TrWindow::savePhraseBook(), Launcher::setup(), HelpDialog::setupFullTextIndex(), QPrintDialogPrivate::setupPrinter(), qdesigner_internal::EditableResourceModel::showWarning(), TrPreviewTool::showWarning(), HelpDialog::startSearch(), TableEditor::submit(), MainWindow::torrentError(), TrWindow::translate(), and DetailsDialog::verify().
01316 { 01317 return showNewMessageBox(parent, Warning, title, text, buttons, defaultButton); 01318 }
Here is the call graph for this function:

| QMessageBox::StandardButton QMessageBox::critical | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| StandardButtons | buttons = Ok, |
|||
| StandardButton | defaultButton = NoButton | |||
| ) | [static] |
Returns the identity of the standard button that was activated. If Esc was pressed, returns the {Default and Escape Keys}{escape button}.
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.
Definition at line 1338 of file qmessagebox.cpp.
References Critical, QObject::parent(), showNewMessageBox(), and text().
Referenced by AssistantServer::AssistantServer(), BookWindow::BookWindow(), HelpDialog::buildContentDict(), HelpDialog::buildKeywordDB(), createConnection(), Dialog::criticalMessage(), QDesignerWorkbench::eventFilter(), main(), MainWindow::on_actionSaveAs_triggered(), Server::Server(), BookWindow::showError(), Dialog::start(), and Q3FileDialog::urlFinished().
01341 { 01342 return showNewMessageBox(parent, Critical, title, text, buttons, defaultButton); 01343 }
Here is the call graph for this function:

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. If not, it tries the top-level widget containing parent. If that fails, it tries the active window. As a last resort it uses the Information icon.
The about box has a single button labelled "OK".
Definition at line 1364 of file qmessagebox.cpp.
References Default, QDialog::exec(), icon(), Information, Ok, QObject::parent(), setIconPixmap(), QWidget::size(), text(), and QWidget::windowIcon().
Referenced by QVFb::about(), Main::about(), ImageViewer::about(), MainWindow::on_aboutAction_triggered(), SpreadSheet::showAbout(), TrPreviewTool::showAboutBox(), and MainWindow::showAboutBox().
01366 { 01367 QMessageBox mb(title, text, Information, Ok + Default, 0, 0, parent); 01368 QIcon icon = mb.windowIcon(); 01369 QSize size = icon.actualSize(QSize(64, 64)); 01370 mb.setIconPixmap(icon.pixmap(size)); 01371 mb.exec(); 01372 }
Here is the call graph for this function:

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. See the examples/menu/menu.cpp example.
QApplication provides this functionality as a slot.
Definition at line 1386 of file qmessagebox.cpp.
References QPalette::Active, addButton(), QPalette::Base, c, QPalette::color(), QDialog::exec(), QPixmap::fromImage(), QPixmap::isNull(), Ok, QWidget::palette(), QObject::parent(), qGray(), qtlogo_xpm, QColor::rgb(), QImage::setColor(), setIconPixmap(), setText(), setWindowTitle(), QPalette::Text, and translatedTextAboutQt.
Referenced by ChatMainWindow::aboutQt(), TrWindow::aboutQt(), Main::aboutQt(), QApplication::aboutQt(), MainWindow::helpAboutQt(), and MainWindow::on_actionAboutApplication_triggered().
01387 { 01388 QMessageBox mb(parent); 01389 01390 QString c = title; 01391 if (c.isEmpty()) 01392 c = tr("About Qt"); 01393 mb.setWindowTitle(c); 01394 mb.setText(*translatedTextAboutQt); 01395 #ifndef QT_NO_IMAGEFORMAT_XPM 01396 QImage logo(qtlogo_xpm); 01397 #else 01398 QImage logo; 01399 #endif 01400 01401 if (qGray(mb.palette().color(QPalette::Active, QPalette::Text).rgb()) > 01402 qGray(mb.palette().color(QPalette::Active, QPalette::Base).rgb())) 01403 { 01404 // light on dark, adjust some colors 01405 logo.setColor(0, 0xffffffff); 01406 logo.setColor(1, 0xff666666); 01407 logo.setColor(2, 0xffcccc66); 01408 logo.setColor(4, 0xffcccccc); 01409 logo.setColor(6, 0xffffff66); 01410 logo.setColor(7, 0xff999999); 01411 logo.setColor(8, 0xff3333ff); 01412 logo.setColor(9, 0xffffff33); 01413 logo.setColor(11, 0xffcccc99); 01414 } 01415 QPixmap pm = QPixmap::fromImage(logo); 01416 if (!pm.isNull()) 01417 mb.setIconPixmap(pm); 01418 mb.addButton(QMessageBox::Ok); 01419 mb.exec(); 01420 }
Here is the call graph for this function:

| QSize QMessageBox::sizeHint | ( | ) | const [virtual] |
Reimplemented from QDialog.
Definition at line 1425 of file qmessagebox.cpp.
References QDialog::sizeHint().
01426 { 01427 // ### Qt 5: remove 01428 return QDialog::sizeHint(); 01429 }
Here is the call graph for this function:

| int QMessageBox::information | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| int | button0, | |||
| int | button1 = 0, |
|||
| int | button2 = 0 | |||
| ) | [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:
QMessageBox::NoButton QMessageBox::Ok QMessageBox::Cancel QMessageBox::Yes QMessageBox::No QMessageBox::Abort QMessageBox::Retry QMessageBox::Ignore QMessageBox::YesAll QMessageBox::NoAll
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.
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.
Definition at line 1654 of file qmessagebox.cpp.
References Information, QObject::parent(), QMessageBoxPrivate::showOldMessageBox(), and text().
01656 { 01657 return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text, 01658 button0, button1, button2); 01659 }
Here is the call graph for this function:

| int QMessageBox::information | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| const QString & | button0Text, | |||
| const QString & | button1Text = QString(), |
|||
| const QString & | button2Text = QString(), |
|||
| int | defaultButtonNumber = 0, |
|||
| int | escapeButtonNumber = -1 | |||
| ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Displays an information message box with the given title and text, as well as one, two or three buttons. Returns the index of the button that was clicked (0, 1 or 2).
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.
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.
Note: If you do not specify an Escape button and no Escape button could be automatically detected, the dialog will not close with the Esc key. It is suggested that you specify an Escape button to prevent this from happening.
Definition at line 1693 of file qmessagebox.cpp.
References Information, QObject::parent(), QMessageBoxPrivate::showOldMessageBox(), and text().
01697 { 01698 return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text, 01699 button0Text, button1Text, button2Text, 01700 defaultButtonNumber, escapeButtonNumber); 01701 }
Here is the call graph for this function:

| int QMessageBox::information | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| StandardButton | button0, | |||
| StandardButton | button1 = NoButton | |||
| ) | [inline, static] |
Definition at line 197 of file qmessagebox.h.
00200 { return information(parent, title, text, StandardButtons(button0), button1); }
| int QMessageBox::question | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| int | button0, | |||
| int | button1 = 0, |
|||
| int | button2 = 0 | |||
| ) | [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:
QMessageBox::NoButton QMessageBox::Ok QMessageBox::Cancel QMessageBox::Yes QMessageBox::No QMessageBox::Abort QMessageBox::Retry QMessageBox::Ignore QMessageBox::YesAll QMessageBox::NoAll
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.
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.
Definition at line 1739 of file qmessagebox.cpp.
References QObject::parent(), Question, QMessageBoxPrivate::showOldMessageBox(), and text().
01741 { 01742 return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text, 01743 button0, button1, button2); 01744 }
Here is the call graph for this function:

| int QMessageBox::question | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| const QString & | button0Text, | |||
| const QString & | button1Text = QString(), |
|||
| const QString & | button2Text = QString(), |
|||
| int | defaultButtonNumber = 0, |
|||
| int | escapeButtonNumber = -1 | |||
| ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Displays a question message box with the given title and text, as well as one, two or three buttons. Returns the index of the button that was clicked (0, 1 or 2).
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.
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.
Note: If you do not specify an Escape button and no Escape button could be automatically detected, the dialog will not close with the Esc key. It is suggested that you specify an Escape button to prevent this from happening.
Definition at line 1777 of file qmessagebox.cpp.
References QObject::parent(), Question, QMessageBoxPrivate::showOldMessageBox(), and text().
01781 { 01782 return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text, 01783 button0Text, button1Text, button2Text, 01784 defaultButtonNumber, escapeButtonNumber); 01785 }
Here is the call graph for this function:

| int QMessageBox::question | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| StandardButton | button0, | |||
| StandardButton | button1 | |||
| ) | [inline, static] |
| int QMessageBox::warning | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| int | button0, | |||
| int | button1, | |||
| int | button2 = 0 | |||
| ) | [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:
QMessageBox::NoButton QMessageBox::Ok QMessageBox::Cancel QMessageBox::Yes QMessageBox::No QMessageBox::Abort QMessageBox::Retry QMessageBox::Ignore QMessageBox::YesAll QMessageBox::NoAll
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.
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.
Definition at line 1824 of file qmessagebox.cpp.
References QObject::parent(), QMessageBoxPrivate::showOldMessageBox(), text(), and Warning.
01826 { 01827 return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text, 01828 button0, button1, button2); 01829 }
Here is the call graph for this function:

| int QMessageBox::warning | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| const QString & | button0Text, | |||
| const QString & | button1Text = QString(), |
|||
| const QString & | button2Text = QString(), |
|||
| int | defaultButtonNumber = 0, |
|||
| int | escapeButtonNumber = -1 | |||
| ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Displays a warning message box with the given title and text, as well as one, two, or three buttons. Returns the number of the button that was clicked (0, 1, or 2).
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.
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.
Note: If you do not specify an Escape button and no Escape button could be automatically detected, the dialog will not close with the Esc key. It is suggested that you specify an Escape button to prevent this from happening.
Definition at line 1862 of file qmessagebox.cpp.
References QObject::parent(), QMessageBoxPrivate::showOldMessageBox(), text(), and Warning.
01866 { 01867 return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text, 01868 button0Text, button1Text, button2Text, 01869 defaultButtonNumber, escapeButtonNumber); 01870 }
Here is the call graph for this function:

| int QMessageBox::warning | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| StandardButton | button0, | |||
| StandardButton | button1 | |||
| ) | [inline, static] |
| int QMessageBox::critical | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| int | button0, | |||
| int | button1, | |||
| int | button2 = 0 | |||
| ) | [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:
QMessageBox::NoButton QMessageBox::Ok QMessageBox::Cancel QMessageBox::Yes QMessageBox::No QMessageBox::Abort QMessageBox::Retry QMessageBox::Ignore QMessageBox::YesAll QMessageBox::NoAll
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.
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.
Definition at line 1909 of file qmessagebox.cpp.
References Critical, QObject::parent(), QMessageBoxPrivate::showOldMessageBox(), and text().
01911 { 01912 return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text, 01913 button0, button1, button2); 01914 }
Here is the call graph for this function:

| int QMessageBox::critical | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| const QString & | button0Text, | |||
| const QString & | button1Text = QString(), |
|||
| const QString & | button2Text = QString(), |
|||
| int | defaultButtonNumber = 0, |
|||
| int | escapeButtonNumber = -1 | |||
| ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Displays a critical error message box with the given title and text, as well as one, two, or three buttons. Returns the number of the button that was clicked (0, 1 or 2).
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.
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.
Definition at line 1942 of file qmessagebox.cpp.
References Critical, QObject::parent(), QMessageBoxPrivate::showOldMessageBox(), and text().
01946 { 01947 return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text, 01948 button0Text, button1Text, button2Text, 01949 defaultButtonNumber, escapeButtonNumber); 01950 }
Here is the call graph for this function:

| int QMessageBox::critical | ( | QWidget * | parent, | |
| const QString & | title, | |||
| const QString & | text, | |||
| StandardButton | button0, | |||
| StandardButton | button1 | |||
| ) | [inline, static] |
| 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 1961 of file qmessagebox.cpp.
01962 { 01963 Q_D(const QMessageBox); 01964 01965 if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) { 01966 return abstractButton->text(); 01967 } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) { 01968 // for compatibility with Qt 4.0/4.1 01969 return QDialogButtonBox::tr("OK"); 01970 } 01971 return QString(); 01972 }
| 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 1983 of file qmessagebox.cpp.
References addButton(), d, Ok, Old_Ok, and text().
Referenced by QDesignerFormWindow::closeEvent(), and QDesignerWorkbench::handleClose().
01984 { 01985 Q_D(QMessageBox); 01986 if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) { 01987 abstractButton->setText(text); 01988 } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) { 01989 // for compatibility with Qt 4.0/4.1 01990 addButton(QMessageBox::Ok)->setText(text); 01991 } 01992 }
Here is the call graph for this function:

| QString QMessageBox::informativeText | ( | ) | const |
Definition at line 2045 of file qmessagebox.cpp.
References d.
02046 { 02047 Q_D(const QMessageBox); 02048 return d->informativeLabel ? d->informativeLabel->text() : QString(); 02049 }
| void QMessageBox::setInformativeText | ( | const QString & | text | ) |
Definition at line 2051 of file qmessagebox.cpp.
References QGridLayout::addWidget(), Qt::AlignLeft, Qt::AlignVCenter, d, QString::isEmpty(), QWidget::layout(), qt_app_fonts_hash(), QLayout::removeWidget(), QLabel::setAlignment(), QWidget::setContentsMargins(), QWidget::setFont(), QLabel::setIndent(), QObject::setObjectName(), QLabel::setOpenExternalLinks(), QLabel::setTextInteractionFlags(), QLabel::setWordWrap(), QStyle::SH_MessageBox_TextInteractionFlags, QWidget::style(), styleHint(), text(), and value.
02052 { 02053 Q_D(QMessageBox); 02054 if (text.isEmpty()) { 02055 layout()->removeWidget(d->informativeLabel); 02056 delete d->informativeLabel; 02057 d->informativeLabel = 0; 02058 #ifndef Q_WS_MAC 02059 d->label->setContentsMargins(2, 0, 0, 0); 02060 #endif 02061 return; 02062 } 02063 02064 if (!d->informativeLabel) { 02065 QLabel *label = new QLabel; 02066 label->setObjectName(QLatin1String("qt_msgbox_informativelabel")); 02067 label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this))); 02068 label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); 02069 label->setOpenExternalLinks(true); 02070 label->setWordWrap(true); 02071 #ifndef Q_WS_MAC 02072 d->label->setContentsMargins(2, 0, 0, 0); 02073 label->setContentsMargins(2, 0, 0, 6); 02074 label->setIndent(9); 02075 #else 02076 label->setContentsMargins(16, 0, 0, 10); 02077 // apply a smaller font the information label on the mac 02078 extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); 02079 label->setFont(qt_app_fonts_hash()->value("QTipLabel")); 02080 #endif 02081 label->setWordWrap(true); 02082 QGridLayout *grid = static_cast<QGridLayout *>(layout()); 02083 grid->addWidget(label, 1, 1, 1, 1); 02084 d->informativeLabel = label; 02085 } 02086 d->informativeLabel->setText(text); 02087 }
Here is the call graph for this function:

| QString QMessageBox::detailedText | ( | ) | const |
Definition at line 2002 of file qmessagebox.cpp.
References d.
02003 { 02004 Q_D(const QMessageBox); 02005 return d->detailsText ? d->detailsText->text() : QString(); 02006 }
| void QMessageBox::setDetailedText | ( | const QString & | text | ) |
Definition at line 2008 of file qmessagebox.cpp.
References QGridLayout::addWidget(), QGridLayout::columnCount(), d, HideLabel, QString::isEmpty(), QWidget::layout(), QDialog::QPushButton, removeButton(), QGridLayout::rowCount(), ShowLabel, and text().
02009 { 02010 Q_D(QMessageBox); 02011 if (text.isEmpty()) { 02012 delete d->detailsText; 02013 d->detailsText = 0; 02014 removeButton(d->detailsButton); 02015 delete d->detailsButton; 02016 d->detailsButton = 0; 02017 return; 02018 } 02019 02020 if (!d->detailsText) { 02021 d->detailsText = new QMessageBoxDetailsText(this); 02022 QGridLayout* grid = qobject_cast<QGridLayout*>(layout()); 02023 if (grid) 02024 grid->addWidget(d->detailsText, grid->rowCount(), 0, 1, grid->columnCount()); 02025 d->detailsText->hide(); 02026 } 02027 if (!d->detailsButton) { 02028 d->detailsButton = new QPushButton(d->detailsText->label(ShowLabel), this); 02029 QPushButton hideDetails(d->detailsText->label(HideLabel)); 02030 d->detailsButton->setFixedSize(d->detailsButton->sizeHint().expandedTo(hideDetails.sizeHint())); 02031 } 02032 d->detailsText->setText(text); 02033 }
Here is the call graph for this function:

| void QMessageBox::setWindowTitle | ( | const QString & | title | ) |
Sets the title of the message box to title. On Mac OS X, the window title is ignored (as required by the Mac OS X Guidelines).
Reimplemented from QWidget.
Definition at line 2098 of file qmessagebox.cpp.
References QWidget::setWindowTitle().
Referenced by TrWindow::about(), MainWindow::about(), aboutQt(), MainWindow::helpAbout(), and MainWindow::on_actionAboutApplication_triggered().
02099 { 02100 // Message boxes on the mac do not have a title 02101 #ifndef Q_WS_MAC 02102 QDialog::setWindowTitle(title); 02103 #else 02104 Q_UNUSED(title); 02105 #endif 02106 }
| void QMessageBox::setWindowModality | ( | Qt::WindowModality | windowModality | ) |
Sets the modality of the message box to windowModality.
On Mac OS X, if the modality is set to 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.
Reimplemented from QWidget.
Definition at line 2120 of file qmessagebox.cpp.
References Qt::Dialog, QWidget::parentWidget(), QWidget::setParent(), QWidget::setWindowModality(), Qt::Sheet, and Qt::WindowModal.
02121 { 02122 QDialog::setWindowModality(windowModality); 02123 02124 if (parentWidget() && windowModality == Qt::WindowModal) 02125 setParent(parentWidget(), Qt::Sheet); 02126 else 02127 setParent(parentWidget(), Qt::Dialog); 02128 }
Here is the call graph for this function:

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::pixelMetric() with QStyle::SP_MessageBoxInformation etc. instead.
Definition at line 2242 of file qmessagebox.cpp.
References Critical, Information, QIcon::isNull(), QStyle::pixelMetric(), QIcon::pixmap(), QStyle::PM_MessageBoxIconSize, QWidget::QPixmap, Question, QStyle::SP_MessageBoxCritical, QStyle::SP_MessageBoxInformation, QStyle::SP_MessageBoxQuestion, QStyle::SP_MessageBoxWarning, QStyle::standardIcon(), QApplication::style(), and Warning.
Referenced by QErrorMessage::QErrorMessage(), and setIcon().
02243 { 02244 int iconSize = QApplication::style()->pixelMetric(QStyle::PM_MessageBoxIconSize); 02245 QIcon tmpIcon; 02246 switch (icon) { 02247 case Information: 02248 tmpIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation); 02249 break; 02250 case Warning: 02251 tmpIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); 02252 break; 02253 case Critical: 02254 tmpIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical); 02255 break; 02256 case Question: 02257 tmpIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion); 02258 default: 02259 break; 02260 } 02261 if (!tmpIcon.isNull()) 02262 return tmpIcon.pixmap(iconSize, iconSize); 02263 return QPixmap(); 02264 }
Here is the call graph for this function:

| void QMessageBox::resizeEvent | ( | QResizeEvent * | event | ) | [protected, virtual] |
Reimplemented from QDialog.
Definition at line 1085 of file qmessagebox.cpp.
References QWidget::event(), and QDialog::resizeEvent().
01086 { 01087 QDialog::resizeEvent(event); 01088 }
Here is the call graph for this function:

| void QMessageBox::showEvent | ( | QShowEvent * | e | ) | [protected, virtual] |
Reimplemented from QDialog.
Definition at line 1181 of file qmessagebox.cpp.
References ActionRole, addButton(), QAccessible::Alert, d, FALSE, Ok, QDialog::showEvent(), QAccessible::updateAccessibility(), and QWidget::winId().
01182 { 01183 Q_D(QMessageBox); 01184 if (d->autoAddOkButton) 01185 addButton(Ok); 01186 if (d->detailsButton) 01187 addButton(d->detailsButton, QMessageBox::ActionRole); 01188 d->detectEscapeButton(); 01189 d->updateSize(); 01190 01191 #ifndef QT_NO_ACCESSIBILITY 01192 QAccessible::updateAccessibility(this, 0, QAccessible::Alert); 01193 #endif 01194 #ifdef Q_WS_WIN 01195 HMENU systemMenu = GetSystemMenu((HWND)winId(), FALSE); 01196 if (!d->detectedEscapeButton) { 01197 EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED); 01198 } 01199 else { 01200 EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED); 01201 } 01202 #endif 01203 QDialog::showEvent(e); 01204 }
Here is the call graph for this function:

| void QMessageBox::closeEvent | ( | QCloseEvent * | e | ) | [protected, virtual] |
Reimplemented from QDialog.
Definition at line 1093 of file qmessagebox.cpp.
References QDialog::closeEvent(), d, QEvent::ignore(), and QDialog::setResult().
01094 { 01095 Q_D(QMessageBox); 01096 if (!d->detectedEscapeButton) { 01097 e->ignore(); 01098 return; 01099 } 01100 QDialog::closeEvent(e); 01101 d->clickedButton = d->detectedEscapeButton; 01102 setResult(d->execReturnCode(d->detectedEscapeButton)); 01103 }
Here is the call graph for this function:

| void QMessageBox::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
Reimplemented from QDialog.
Definition at line 1141 of file qmessagebox.cpp.
References Qt::AltModifier, QList< T >::at(), Qt::ControlModifier, QList< T >::count(), d, i, int, QKeyEvent::key(), key, Qt::Key_Escape, Qt::Key_Period, QDialog::keyPressEvent(), Qt::MODIFIER_MASK, QKeyEvent::modifiers(), QAbstractButton::shortcut(), and Qt::UNICODE_ACCEL.
01142 { 01143 Q_D(QMessageBox); 01144 if (e->key() == Qt::Key_Escape 01145 #ifdef Q_WS_MAC 01146 || (e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period) 01147 #endif 01148 ) { 01149 if (d->detectedEscapeButton) { 01150 #ifdef Q_WS_MAC 01151 d->detectedEscapeButton->animateClick(); 01152 #else 01153 d->detectedEscapeButton->click(); 01154 #endif 01155 } 01156 return; 01157 } 01158 01159 #ifndef QT_NO_SHORTCUT 01160 if (!(e->modifiers() & Qt::AltModifier)) { 01161 int key = e->key() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL); 01162 if (key) { 01163 const QList<QAbstractButton *> buttons = d->buttonBox->buttons(); 01164 for (int i = 0; i < buttons.count(); ++i) { 01165 QAbstractButton *pb = buttons.at(i); 01166 int acc = pb->shortcut() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL); 01167 if (acc == key) { 01168 pb->animateClick(); 01169 return; 01170 } 01171 } 01172 } 01173 } 01174 #endif 01175 QDialog::keyPressEvent(e); 01176 }
Here is the call graph for this function:

| void QMessageBox::changeEvent | ( | QEvent * | ev | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1108 of file qmessagebox.cpp.
References QEvent::ApplicationFontChange, QWidget::changeEvent(), d, flags, QWidget::font(), QEvent::FontChange, NoIcon, QFont::setBold(), setIcon(), QStyle::SH_MessageBox_CenterButtons, QStyle::SH_MessageBox_TextInteractionFlags, QWidget::style(), QEvent::StyleChange, styleHint(), and QEvent::type().
01109 { 01110 Q_D(QMessageBox); 01111 switch (ev->type()) { 01112 case QEvent::StyleChange: 01113 { 01114 if (d->icon != NoIcon) 01115 setIcon(d->icon); 01116 Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this)); 01117 d->label->setTextInteractionFlags(flags); 01118 d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, this)); 01119 if (d->informativeLabel) 01120 d->informativeLabel->setTextInteractionFlags(flags); 01121 // intentional fall through 01122 } 01123 case QEvent::FontChange: 01124 case QEvent::ApplicationFontChange: 01125 #ifdef Q_WS_MAC 01126 { 01127 QFont f = font(); 01128 f.setBold(true); 01129 d->label->setFont(f); 01130 } 01131 #endif 01132 default: 01133 break; 01134 } 01135 QDialog::changeEvent(ev); 01136 }
Here is the call graph for this function:

1.5.1