1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/dialogs/qmessagebox.cpp -->
7
<title>Qt 4.0: QMessageBox Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QMessageBox Class Reference</h1>
21
<p>The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons. <a href="#details">More...</a></p>
22
<pre>#include <QMessageBox></pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
23
<p>Inherits <a href="qdialog.html">QDialog</a>.</p>
25
<li><a href="qmessagebox-members.html">List of all members, including inherited members</a></li>
26
<li><a href="qmessagebox-qt3.html">Qt 3 support members</a></li>
28
<a name="public-types"></a>
31
<li><div class="fn"/>enum <b><a href="qmessagebox.html#Button-enum">Button</a></b> { Ok, Cancel, Yes, No, ..., NoButton }</li>
32
<li><div class="fn"/>enum <b><a href="qmessagebox.html#Icon-enum">Icon</a></b> { NoIcon, Question, Information, Warning, Critical }</li>
34
<a name="properties"></a>
37
<li><div class="fn"/><b><a href="qmessagebox.html#icon-prop">icon</a></b> : Icon</li>
38
<li><div class="fn"/><b><a href="qmessagebox.html#iconPixmap-prop">iconPixmap</a></b> : QPixmap</li>
39
<li><div class="fn"/><b><a href="qmessagebox.html#text-prop">text</a></b> : QString</li>
40
<li><div class="fn"/><b><a href="qmessagebox.html#textFormat-prop">textFormat</a></b> : Qt::TextFormat</li>
43
<li><div class="fn"/>2 properties inherited from <a href="qdialog.html#properties">QDialog</a></li>
44
<li><div class="fn"/>52 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
45
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
47
<a name="public-functions"></a>
48
<h3>Public Functions</h3>
50
<li><div class="fn"/><b><a href="qmessagebox.html#QMessageBox">QMessageBox</a></b> ( QWidget * <i>parent</i> = 0 )</li>
51
<li><div class="fn"/><b><a href="qmessagebox.html#QMessageBox-2">QMessageBox</a></b> ( const QString & <i>caption</i>, const QString & <i>text</i>, Icon <i>icon</i>, int <i>button0</i>, int <i>button1</i>, int <i>button2</i>, QWidget * <i>parent</i> = 0, Qt::WFlags <i>f</i> = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint )</li>
52
<li><div class="fn"/><b><a href="qmessagebox.html#dtor.QMessageBox">~QMessageBox</a></b> ()</li>
53
<li><div class="fn"/>QString <b><a href="qmessagebox.html#buttonText">buttonText</a></b> ( int <i>button</i> ) const</li>
54
<li><div class="fn"/>Icon <b><a href="qmessagebox.html#icon-prop">icon</a></b> () const</li>
55
<li><div class="fn"/>QPixmap <b><a href="qmessagebox.html#iconPixmap-prop">iconPixmap</a></b> () const</li>
56
<li><div class="fn"/>void <b><a href="qmessagebox.html#setButtonText">setButtonText</a></b> ( int <i>button</i>, const QString & <i>text</i> )</li>
57
<li><div class="fn"/>void <b><a href="qmessagebox.html#icon-prop">setIcon</a></b> ( Icon )</li>
58
<li><div class="fn"/>void <b><a href="qmessagebox.html#iconPixmap-prop">setIconPixmap</a></b> ( const QPixmap & )</li>
59
<li><div class="fn"/>void <b><a href="qmessagebox.html#text-prop">setText</a></b> ( const QString & )</li>
60
<li><div class="fn"/>void <b><a href="qmessagebox.html#textFormat-prop">setTextFormat</a></b> ( Qt::TextFormat )</li>
61
<li><div class="fn"/>QString <b><a href="qmessagebox.html#text-prop">text</a></b> () const</li>
62
<li><div class="fn"/>Qt::TextFormat <b><a href="qmessagebox.html#textFormat-prop">textFormat</a></b> () const</li>
65
<li><div class="fn"/>9 public functions inherited from <a href="qdialog.html#public-functions">QDialog</a></li>
66
<li><div class="fn"/>183 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
67
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
68
<li><div class="fn"/>10 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
70
<a name="static-public-members"></a>
71
<h3>Static Public Members</h3>
73
<li><div class="fn"/>void <b><a href="qmessagebox.html#about">about</a></b> ( QWidget * <i>parent</i>, const QString & <i>caption</i>, const QString & <i>text</i> )</li>
74
<li><div class="fn"/>void <b><a href="qmessagebox.html#aboutQt">aboutQt</a></b> ( QWidget * <i>parent</i>, const QString & <i>caption</i> = QString() )</li>
75
<li><div class="fn"/>int <b><a href="qmessagebox.html#critical">critical</a></b> ( QWidget * <i>parent</i>, const QString & <i>caption</i>, const QString & <i>text</i>, int <i>button0</i>, int <i>button1</i>, int <i>button2</i> = 0 )</li>
76
<li><div class="fn"/>int <b><a href="qmessagebox.html#critical-2">critical</a></b> ( QWidget * <i>parent</i>, const QString & <i>caption</i>, const QString & <i>text</i>, const QString & <i>button0Text</i> = QString(), const QString & <i>button1Text</i> = QString(), const QString & <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 )</li>
77
<li><div class="fn"/>int <b><a href="qmessagebox.html#information">information</a></b> ( QWidget * <i>parent</i>, const QString & <i>caption</i>, const QString & <i>text</i>, int <i>button0</i>, int <i>button1</i> = 0, int <i>button2</i> = 0 )</li>
78
<li><div class="fn"/>int <b><a href="qmessagebox.html#information-2">information</a></b> ( QWidget * <i>parent</i>, const QString & <i>caption</i>, const QString & <i>text</i>, const QString & <i>button0Text</i> = QString(), const QString & <i>button1Text</i> = QString(), const QString & <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 )</li>
79
<li><div class="fn"/>int <b><a href="qmessagebox.html#question">question</a></b> ( QWidget * <i>parent</i>, const QString & <i>caption</i>, const QString & <i>text</i>, int <i>button0</i>, int <i>button1</i> = 0, int <i>button2</i> = 0 )</li>
80
<li><div class="fn"/>int <b><a href="qmessagebox.html#question-2">question</a></b> ( QWidget * <i>parent</i>, const QString & <i>caption</i>, const QString & <i>text</i>, const QString & <i>button0Text</i> = QString(), const QString & <i>button1Text</i> = QString(), const QString & <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 )</li>
81
<li><div class="fn"/>QPixmap <b><a href="qmessagebox.html#standardIcon-2">standardIcon</a></b> ( Icon <i>icon</i> )</li>
82
<li><div class="fn"/>int <b><a href="qmessagebox.html#warning">warning</a></b> ( QWidget * <i>parent</i>, const QString & <i>caption</i>, const QString & <i>text</i>, int <i>button0</i>, int <i>button1</i>, int <i>button2</i> = 0 )</li>
83
<li><div class="fn"/>int <b><a href="qmessagebox.html#warning-2">warning</a></b> ( QWidget * <i>parent</i>, const QString & <i>caption</i>, const QString & <i>text</i>, const QString & <i>button0Text</i> = QString(), const QString & <i>button1Text</i> = QString(), const QString & <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 )</li>
86
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
87
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
92
<li><div class="fn"/><b><a href="qmessagebox.html#QT_REQUIRE_VERSION">QT_REQUIRE_VERSION</a></b> ( int <i>argc</i>, char ** <i>argv</i>, const char * <i>version</i> )</li>
94
<h3>Additional Inherited Members</h3>
96
<li><div class="fn"/>5 public slots inherited from <a href="qdialog.html#public-slots">QDialog</a></li>
97
<li><div class="fn"/>17 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
98
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
99
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
100
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
101
<li><div class="fn"/>39 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
102
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
104
<a name="details"></a>
106
<h2>Detailed Description</h2>
107
<p>The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons.</p>
108
<p>Message boxes are used to provide informative messages and to ask simple questions.</p>
109
<p>QMessageBox provides a range of different messages, arranged roughly along two axes: severity and complexity.</p>
111
<table align="center" cellpadding="2" cellspacing="1" border="0">
112
<tr valign="top" bgcolor="#f0f0f0"><td><center><img src="images/qmessagebox-quest.png" /></center></td><td>Question</td><td>For message boxes that ask a question as part of normal operation. Some style guides recommend using Information for this purpose.</td></tr>
113
<tr valign="top" bgcolor="#e0e0e0"><td><center><img src="images/qmessagebox-info.png" /></center></td><td>Information</td><td>For message boxes that are part of normal operation.</td></tr>
114
<tr valign="top" bgcolor="#f0f0f0"><td><center><img src="images/qmessagebox-warn.png" /></center></td><td>Warning</td><td>For message boxes that tell the user about unusual errors.</td></tr>
115
<tr valign="top" bgcolor="#e0e0e0"><td><center><img src="images/qmessagebox-crit.png" /></center></td><td>Critical</td><td>For message boxes that tell the user about critical errors.</td></tr>
117
<p>The message box has a different icon for each of the severity levels.</p>
118
<p>Complexity is one button (OK) for simple messages, or two or even three buttons for questions.</p>
119
<p>There are static functions for the most common cases.</p>
121
<p>If a program is unable to find a supporting file, but can do perfectly well without it:</p>
122
<pre> QMessageBox::information(this, "Application name",
123
"Unable to find the user preferences file.\n"
124
"The factory default will be used instead.");</pre>
125
<p><a href="qmessagebox.html#question">question</a>() is useful for simple yes/no questions:</p>
126
<pre> if (QFile::exists(filename) &&
127
QMessageBox::question(
129
tr("Overwrite File? -- Application Name"),
130
tr("A file called %1 already exists."
131
"Do you want to overwrite it?")
133
tr("&Yes"), tr("&No"),
136
<p><a href="qmessagebox.html#warning">warning</a>() can be used to tell the user about unusual errors, or errors which can't be easily fixed:</p>
137
<pre> switch(QMessageBox::warning(this, "Application name",
138
"Could not connect to the <mumble> server.\n"
139
"This program can't function correctly "
140
"without the server.\n\n",
142
"Quit", 0, 0, 1)) {
143
case 0: // The user clicked the Retry again button or pressed Enter
146
case 1: // The user clicked the Quit or pressed Escape
150
<p>The text part of all message box messages can be either rich text or plain text. If you specify a rich text formatted string, it will be rendered using the default stylesheet. See QStyleSheet::defaultSheet() for details. 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 QStyleSheet::convertFromPlainText() to convert your plain text string to a visually equivalent rich text string or set the text format explicitly with <a href="qmessagebox.html#textFormat-prop">setTextFormat</a>().</p>
151
<p>Note that the Microsoft Windows User Interface Guidelines recommend using the application name as the window's caption.</p>
152
<p>Below are more examples of how to use the static member functions. After these examples you will find an overview of the non-static member functions.</p>
153
<p>Exiting a program is part of its normal operation. If there is unsaved data the user probably should be asked if they want to save the data. For example:</p>
154
<pre> switch(QMessageBox::information(this, "Application name here",
155
"The document contains unsaved changes\n"
156
"Do you want to save the changes before exiting?",
157
"&Save", "&Discard", "Cancel",
158
0, // Enter == button 0
159
2)) { // Escape == button 2
160
case 0: // Save clicked or Alt+S pressed or Enter pressed.
163
case 1: // Discard clicked or Alt+D pressed
164
// don't save but exit
166
case 2: // Cancel clicked or Escape pressed
170
<p>The Escape button cancels the entire exit operation, and pressing Enter causes the changes to be saved before the exit occurs.</p>
171
<p>Disk full errors are unusual and they certainly can be hard to correct. This example uses predefined buttons instead of hard-coded button texts:</p>
172
<pre> switch(QMessageBox::warning(this, "Application name here",
173
"Could not save the user preferences,\n"
174
"because the disk is full. You can delete\n"
175
"some files and press Retry, or you can\n"
176
"abort the Save Preferences operation.",
177
QMessageBox::Retry | QMessageBox::Default,
178
QMessageBox::Abort | QMessageBox::Escape)) {
179
case QMessageBox::Retry: // Retry clicked or Enter pressed
182
case QMessageBox::Abort: // Abort clicked or Escape pressed
186
<p>The <a href="qmessagebox.html#critical">critical</a>() function should be reserved for critical errors. In this example errorDetails is a <a href="qstring.html">QString</a> or const char*, and <a href="qstring.html">QString</a> is used to concatenate several strings:</p>
187
<pre> QMessageBox::critical(0, "Application name here",
188
QString("An internal error occurred. Please ") +
189
"call technical support at 1234-56789 and report\n"+
190
"these numbers:\n\n" + errorDetails +
191
"\n\nApplication will now exit.");</pre>
192
<p>In this example an OK button is displayed.</p>
193
<p>QMessageBox provides a very simple About box which displays an appropriate icon and the string you provide:</p>
194
<pre> QMessageBox::about(this, "About <Application>",
195
"<Application> is a <one-paragraph blurb>\n\n"
196
"Copyright 1991-2003 Such-and-such. "
197
"<License words here.>\n\n"
198
"For technical support, call 1234-56789 or see\n"
199
"http://www.such-and-such.com/Application/\n");</pre>
200
<p>See <a href="qmessagebox.html#about">about</a>() for more information.</p>
201
<p>If you want your users to know that the application is built using Qt (so they know that you use high quality tools) you might like to add an "About Qt" menu option under the Help menu to invoke <a href="qmessagebox.html#aboutQt">aboutQt</a>().</p>
202
<p>If none of the standard message boxes is suitable, you can create a QMessageBox from scratch and use custom button texts:</p>
203
<pre> QMessageBox mb("Application name here",
204
"Saving the file will overwrite the original file on the disk.\n"
205
"Do you really want to save?",
206
QMessageBox::Information,
207
QMessageBox::Yes | QMessageBox::Default,
209
QMessageBox::Cancel | QMessageBox::Escape);
210
mb.setButtonText(QMessageBox::Yes, "Save");
211
mb.setButtonText(QMessageBox::No, "Discard");
213
case QMessageBox::Yes:
216
case QMessageBox::No:
217
// exit without saving
219
case QMessageBox::Cancel:
220
// don't save and don't exit
223
<p>QMessageBox defines two enum types: Icon and an unnamed button type. Icon defines the <tt>Question</tt>, <tt>Information</tt>, <tt>Warning</tt>, and <tt>Critical</tt> icons for each GUI style. It is used by the constructor and by the static member functions <a href="qmessagebox.html#question">question</a>(), <a href="qmessagebox.html#information">information</a>(), <a href="qmessagebox.html#warning">warning</a>() and <a href="qmessagebox.html#critical">critical</a>(). A function called <a href="qmessagebox-qt3.html#standardIcon">standardIcon</a>() gives you access to the various icons.</p>
224
<p>The button types are:</p>
226
<li>Ok - the default for single-button message boxes</li>
227
<li>Cancel - note that this is <i>not</i> automatically Escape</li>
233
<li><a href="qmessagebox.html#Button-enum">YesAll</a></li>
234
<li><a href="qmessagebox.html#Button-enum">NoAll</a></li>
236
<p>Button types can be combined with two modifiers by using OR, '|':</p>
238
<li>Default - makes pressing Enter equivalent to clicking this button. Normally used with Ok, Yes or similar.</li>
239
<li>Escape - makes pressing Escape equivalent to clicking this button. Normally used with Abort, Cancel or similar.</li>
241
<p>The <a href="qmessagebox.html#text-prop">text</a>(), <a href="qmessagebox.html#icon-prop">icon</a>() and <a href="qmessagebox.html#iconPixmap-prop">iconPixmap</a>() functions provide access to the current text and pixmap of the message box. The <a href="qmessagebox.html#text-prop">setText</a>(), <a href="qmessagebox.html#icon-prop">setIcon</a>() and <a href="qmessagebox.html#iconPixmap-prop">setIconPixmap</a>() let you change it. The difference between <a href="qmessagebox.html#icon-prop">setIcon</a>() and <a href="qmessagebox.html#iconPixmap-prop">setIconPixmap</a>() is that the former accepts a <a href="qmessagebox.html#Icon-enum">QMessageBox::Icon</a> and can be used to set standard icons, whereas the latter accepts a <a href="qpixmap.html">QPixmap</a> and can be used to set custom icons.</p>
242
<p><a href="qmessagebox.html#setButtonText">setButtonText</a>() and <a href="qmessagebox.html#buttonText">buttonText</a>() provide access to the buttons.</p>
243
<p>QMessageBox has no signals or slots.</p>
244
<p>The <a href="dialogs-standarddialogs.html">Standard Dialogs</a> example shows how to use QMessageBox as well as other built-in Qt dialogs.</p>
245
<p><img src="images/qmsgbox-m.png" alt="Screenshot in Motif style" /> <img src="images/qmsgbox-w.png" alt="Screenshot in Windows style" /></p>
246
<p>See also <a href="qdialog.html">QDialog</a> and <a href="guibooks.html#fowler">GUI Design Handbook: Message Box</a>.</p>
248
<h2>Member Type Documentation</h2>
249
<h3 class="fn"><a name="Button-enum"></a>enum QMessageBox::Button</h3>
250
<p>This enum describes the predefined buttons and button flags you can assign to a <a href="qmessagebox.html">QMessageBox</a>.</p>
251
<table border="1" cellpadding="2" cellspacing="1" width="100%">
252
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
253
<tr><td valign="top"><tt>QMessageBox::Ok</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">An "Ok" button.</td></tr>
254
<tr><td valign="top"><tt>QMessageBox::Cancel</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">A "Cancel" button.</td></tr>
255
<tr><td valign="top"><tt>QMessageBox::Yes</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">A "Yes" button.</td></tr>
256
<tr><td valign="top"><tt>QMessageBox::No</tt></td><td align="center" valign="top"><tt>4</tt></td><td valign="top">A "No" button.</td></tr>
257
<tr><td valign="top"><tt>QMessageBox::Abort</tt></td><td align="center" valign="top"><tt>5</tt></td><td valign="top">An "Abort" button.</td></tr>
258
<tr><td valign="top"><tt>QMessageBox::Retry</tt></td><td align="center" valign="top"><tt>6</tt></td><td valign="top">A "Retry" button.</td></tr>
259
<tr><td valign="top"><tt>QMessageBox::Ignore</tt></td><td align="center" valign="top"><tt>7</tt></td><td valign="top">An "Ignore" button.</td></tr>
260
<tr><td valign="top"><tt>QMessageBox::YesAll</tt></td><td align="center" valign="top"><tt>8</tt></td><td valign="top">A "Yes to all" button.</td></tr>
261
<tr><td valign="top"><tt>QMessageBox::NoAll</tt></td><td align="center" valign="top"><tt>9</tt></td><td valign="top">A "No to all" button.</td></tr>
263
<p>The following values are flags that can be OR'ed with the button values.</p>
264
<table border="1" cellpadding="2" cellspacing="1" width="100%">
265
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
266
<tr><td valign="top"><tt>QMessageBox::Default</tt></td><td align="center" valign="top"><tt>0x100</tt></td><td valign="top">The button is default (i.e., <a href="qpushbutton.html#default-prop">QPushButton::default</a>).</td></tr>
267
<tr><td valign="top"><tt>QMessageBox::Escape</tt></td><td align="center" valign="top"><tt>0x200</tt></td><td valign="top">The button is activated by pressing the Escape key.</td></tr>
269
<p>The following values are masks that can be used to separate buttons from flags.</p>
270
<table border="1" cellpadding="2" cellspacing="1" width="100%">
271
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
272
<tr><td valign="top"><tt>QMessageBox::ButtonMask</tt></td><td align="center" valign="top"><tt>0xff</tt></td><td valign="top">A bitmask that covers all button types.</td></tr>
273
<tr><td valign="top"><tt>QMessageBox::FlagMask</tt></td><td align="center" valign="top"><tt>0x300</tt></td><td valign="top">A bitmask that covers all button flags.</td></tr>
275
<p>Finally, the last value is often used as a default value.</p>
276
<table border="1" cellpadding="2" cellspacing="1" width="40%">
277
<tr><th width="60%">Constant</th><th width="40%">Value</th></tr>
278
<tr><td valign="top"><tt>QMessageBox::NoButton</tt></td><td align="center" valign="top"><tt>0</tt></td></tr>
280
<h3 class="fn"><a name="Icon-enum"></a>enum QMessageBox::Icon</h3>
281
<p>This enum has the following values:</p>
282
<table border="1" cellpadding="2" cellspacing="1" width="100%">
283
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
284
<tr><td valign="top"><tt>QMessageBox::NoIcon</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">the message box does not have any icon.</td></tr>
285
<tr><td valign="top"><tt>QMessageBox::Question</tt></td><td align="center" valign="top"><tt>4</tt></td><td valign="top">an icon indicating that the message is asking a question.</td></tr>
286
<tr><td valign="top"><tt>QMessageBox::Information</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">an icon indicating that the message is nothing out of the ordinary.</td></tr>
287
<tr><td valign="top"><tt>QMessageBox::Warning</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">an icon indicating that the message is a warning, but can be dealt with.</td></tr>
288
<tr><td valign="top"><tt>QMessageBox::Critical</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">an icon indicating that the message represents a critical problem.</td></tr>
291
<h2>Property Documentation</h2>
292
<h3 class="fn"><a name="icon-prop"></a>icon : <a href="qmessagebox.html#Icon-enum">Icon</a></h3>
293
<p>This property holds the message box's icon.</p>
294
<p>The icon of the message box can be one of the following predefined icons:</p>
296
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::NoIcon</a></li>
297
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Question</a></li>
298
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Information</a></li>
299
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Warning</a></li>
300
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Critical</a></li>
302
<p>The actual pixmap used for displaying the icon depends on the current <a href="qwidget.html#style">GUI style</a>. You can also set a custom pixmap icon using the <a href="qmessagebox.html#iconPixmap-prop">QMessageBox::iconPixmap</a> property. The default icon is <a href="qmessagebox.html#Icon-enum">QMessageBox::NoIcon</a>.</p>
303
<p>Access functions:</p>
305
<li><div class="fn"/><b>Icon icon () const</b></li>
306
<li><div class="fn"/><b>void setIcon ( Icon )</b></li>
308
<p>See also <a href="qmessagebox.html#iconPixmap-prop">iconPixmap</a>.</p>
309
<h3 class="fn"><a name="iconPixmap-prop"></a>iconPixmap : <a href="qpixmap.html">QPixmap</a></h3>
310
<p>This property holds the current icon.</p>
311
<p>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.</p>
312
<p>Access functions:</p>
314
<li><div class="fn"/><b>QPixmap iconPixmap () const</b></li>
315
<li><div class="fn"/><b>void setIconPixmap ( const QPixmap & )</b></li>
317
<p>See also <a href="qmessagebox.html#icon-prop">icon</a>.</p>
318
<h3 class="fn"><a name="text-prop"></a>text : <a href="qstring.html">QString</a></h3>
319
<p>This property holds the message box text to be displayed.</p>
320
<p>The text will be interpreted either as a plain text or as rich text, depending on the text format setting (<a href="qmessagebox.html#textFormat-prop">QMessageBox::textFormat</a>). The default setting is <tt>Qt::AutoText</tt>, i.e. the message box will try to auto-detect the format of the text.</p>
321
<p>The default value of this property is an empty string.</p>
322
<p>Access functions:</p>
324
<li><div class="fn"/><b>QString text () const</b></li>
325
<li><div class="fn"/><b>void setText ( const QString & )</b></li>
327
<p>See also <a href="qmessagebox.html#textFormat-prop">textFormat</a>.</p>
328
<h3 class="fn"><a name="textFormat-prop"></a>textFormat : <a href="qt.html#TextFormat-enum">Qt::TextFormat</a></h3>
329
<p>This property holds the format of the text displayed by the message box.</p>
330
<p>The current text format used by the message box. See the <a href="qt.html#TextFormat-enum">Qt::TextFormat</a> enum for an explanation of the possible options.</p>
331
<p>The default format is <tt>Qt::AutoText</tt>.</p>
332
<p>Access functions:</p>
334
<li><div class="fn"/><b>Qt::TextFormat textFormat () const</b></li>
335
<li><div class="fn"/><b>void setTextFormat ( Qt::TextFormat )</b></li>
337
<p>See also <a href="qmessagebox.html#text-prop">setText</a>().</p>
339
<h2>Member Function Documentation</h2>
340
<h3 class="fn"><a name="QMessageBox"></a>QMessageBox::QMessageBox ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
341
<p>Constructs a message box with no text and a button with the label "OK".</p>
342
<p>If <i>parent</i> is 0, the message box becomes an application-global modal dialog box. If <i>parent</i> is a widget, the message box becomes modal relative to <i>parent</i>.</p>
343
<p>The <i>parent</i> argument is passed to the <a href="qdialog.html">QDialog</a> constructor.</p>
344
<h3 class="fn"><a name="QMessageBox-2"></a>QMessageBox::QMessageBox ( const <a href="qstring.html">QString</a> & <i>caption</i>, const <a href="qstring.html">QString</a> & <i>text</i>, <a href="qmessagebox.html#Icon-enum">Icon</a> <i>icon</i>, int <i>button0</i>, int <i>button1</i>, int <i>button2</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>f</i> = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint )</h3>
345
<p>Constructs a message box with a <i>caption</i>, a <i>text</i>, an <i>icon</i>, and up to three buttons.</p>
346
<p>The <i>icon</i> must be one of the following:</p>
348
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::NoIcon</a></li>
349
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Question</a></li>
350
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Information</a></li>
351
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Warning</a></li>
352
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Critical</a></li>
354
<p>Each button, <i>button0</i>, <i>button1</i> and <i>button2</i>, can have one of the following values:</p>
356
<li><a href="qmessagebox.html#Button-enum">QMessageBox::NoButton</a></li>
357
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Ok</a></li>
358
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Cancel</a></li>
359
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Yes</a></li>
360
<li><a href="qmessagebox.html#Button-enum">QMessageBox::No</a></li>
361
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Abort</a></li>
362
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Retry</a></li>
363
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Ignore</a></li>
364
<li><a href="qmessagebox.html#Button-enum">QMessageBox::YesAll</a></li>
365
<li><a href="qmessagebox.html#Button-enum">QMessageBox::NoAll</a></li>
367
<p>Use <a href="qmessagebox.html#Button-enum">QMessageBox::NoButton</a> for the later parameters to have fewer than three buttons in your message box. If you don't specify any buttons at all, <a href="qmessagebox.html">QMessageBox</a> will provide an Ok button.</p>
368
<p>One of the buttons can be OR-ed with the <tt>QMessageBox::Default</tt> flag to make it the default button (clicked when Enter is pressed).</p>
369
<p>One of the buttons can be OR-ed with the <tt>QMessageBox::Escape</tt> flag to make it the cancel or close button (clicked when Escape is pressed).</p>
370
<pre> QMessageBox mb("Application Name",
371
"Hardware failure.\n\nDisk error detected\nDo you want to stop?",
372
QMessageBox::Question,
373
QMessageBox::Yes | QMessageBox::Default,
374
QMessageBox::No | QMessageBox::Escape,
375
QMessageBox::NoButton);
376
if (mb.exec() == QMessageBox::No) {
378
<p>If <i>parent</i> is 0, the message box becomes an application-global modal dialog box. If <i>parent</i> is a widget, the message box becomes modal relative to <i>parent</i>.</p>
379
<p>The <i>parent</i> and <i>f</i> arguments are passed to the <a href="qdialog.html">QDialog</a> constructor.</p>
380
<p>See also <a href="qwidget.html#windowTitle-prop">setWindowTitle</a>(), <a href="qmessagebox.html#text-prop">setText</a>(), and <a href="qmessagebox.html#icon-prop">setIcon</a>().</p>
381
<h3 class="fn"><a name="dtor.QMessageBox"></a>QMessageBox::~QMessageBox ()</h3>
382
<p>Destroys the message box.</p>
383
<h3 class="fn"><a name="about"></a>void QMessageBox::about ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> & <i>caption</i>, const <a href="qstring.html">QString</a> & <i>text</i> ) <tt> [static]</tt></h3>
384
<p>Displays a simple about box with caption <i>caption</i> and text <i>text</i>. The about box's parent is <i>parent</i>.</p>
385
<p>about() looks for a suitable icon in four locations:</p>
387
<li>It prefers <a href="qwidget.html#windowIcon-prop">parent->icon()</a> if that exists.</li>
388
<li>If not, it tries the top-level widget containing <i>parent</i>.</li>
389
<li>If that fails, it tries the <a href="qapplication.html#activeWindow">active window.</a></li>
390
<li>As a last resort it uses the Information icon.</li>
392
<p>The about box has a single button labelled "OK".</p>
393
<p>See also <a href="qwidget.html#windowIcon-prop">QWidget::windowIcon</a>() and <a href="qapplication.html#activeWindow">QApplication::activeWindow</a>().</p>
394
<h3 class="fn"><a name="aboutQt"></a>void QMessageBox::aboutQt ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> & <i>caption</i> = QString() ) <tt> [static]</tt></h3>
395
<p>Displays a simple message box about Qt, with caption <i>caption</i> and centered over <i>parent</i> (if <i>parent</i> is not 0). The message includes the version number of Qt being used by the application.</p>
396
<p>This is useful for inclusion in the Help menu of an application. See the examples/menu/menu.cpp example.</p>
397
<p><a href="qapplication.html">QApplication</a> provides this functionality as a slot.</p>
398
<p>See also <a href="qapplication.html#aboutQt">QApplication::aboutQt</a>().</p>
399
<h3 class="fn"><a name="buttonText"></a><a href="qstring.html">QString</a> QMessageBox::buttonText ( int <i>button</i> ) const</h3>
400
<p>Returns the text of the message box button <i>button</i>, or an empty string if the message box does not contain the button.</p>
401
<p>See also <a href="qmessagebox.html#setButtonText">setButtonText</a>().</p>
402
<h3 class="fn"><a name="critical"></a>int QMessageBox::critical ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> & <i>caption</i>, const <a href="qstring.html">QString</a> & <i>text</i>, int <i>button0</i>, int <i>button1</i>, int <i>button2</i> = 0 ) <tt> [static]</tt></h3>
403
<p>Opens a critical message box with the caption <i>caption</i> and the text <i>text</i>. The dialog may have up to three buttons. Each of the button parameters, <i>button0</i>, <i>button1</i> and <i>button2</i> may be set to one of the following values:</p>
405
<li><a href="qmessagebox.html#Button-enum">QMessageBox::NoButton</a></li>
406
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Ok</a></li>
407
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Cancel</a></li>
408
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Yes</a></li>
409
<li><a href="qmessagebox.html#Button-enum">QMessageBox::No</a></li>
410
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Abort</a></li>
411
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Retry</a></li>
412
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Ignore</a></li>
413
<li><a href="qmessagebox.html#Button-enum">QMessageBox::YesAll</a></li>
414
<li><a href="qmessagebox.html#Button-enum">QMessageBox::NoAll</a></li>
416
<p>If you don't want all three buttons, set the last button, or last two buttons to <a href="qmessagebox.html#Button-enum">QMessageBox::NoButton</a>.</p>
417
<p>One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one button can be OR-ed with <tt>QMessageBox::Escape</tt>.</p>
418
<p>Returns the identity (<a href="qmessagebox.html#Button-enum">QMessageBox::Ok</a>, or <a href="qmessagebox.html#Button-enum">QMessageBox::No</a>, etc.) of the button that was clicked.</p>
419
<p>If <i>parent</i> is 0, the message box becomes an application-global modal dialog box. If <i>parent</i> is a widget, the message box becomes modal relative to <i>parent</i>.</p>
420
<p>See also <a href="qmessagebox.html#information">information</a>(), <a href="qmessagebox.html#question">question</a>(), and <a href="qmessagebox.html#warning">warning</a>().</p>
421
<h3 class="fn"><a name="critical-2"></a>int QMessageBox::critical ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> & <i>caption</i>, const <a href="qstring.html">QString</a> & <i>text</i>, const <a href="qstring.html">QString</a> & <i>button0Text</i> = QString(), const <a href="qstring.html">QString</a> & <i>button1Text</i> = QString(), const <a href="qstring.html">QString</a> & <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 ) <tt> [static]</tt></h3>
422
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
423
<p>Displays a critical error message box with a caption, a text, and 1, 2 or 3 buttons. Returns the number of the button that was clicked (0, 1 or 2).</p>
424
<p><i>button0Text</i> is the text of the first button, and is optional. If <i>button0Text</i> is not supplied, "OK" (translated) will be used. <i>button1Text</i> is the text of the second button, and is optional, and <i>button2Text</i> is the text of the third button, and is optional. <i>defaultButtonNumber</i> (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). <i>escapeButtonNumber</i> 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.</p>
425
<p>If <i>parent</i> is 0, the message box becomes an application-global modal dialog box. If <i>parent</i> is a widget, the message box becomes modal relative to <i>parent</i>.</p>
426
<p>See also <a href="qmessagebox.html#information">information</a>(), <a href="qmessagebox.html#question">question</a>(), and <a href="qmessagebox.html#warning">warning</a>().</p>
427
<h3 class="fn"><a name="information"></a>int QMessageBox::information ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> & <i>caption</i>, const <a href="qstring.html">QString</a> & <i>text</i>, int <i>button0</i>, int <i>button1</i> = 0, int <i>button2</i> = 0 ) <tt> [static]</tt></h3>
428
<p>Opens an information message box with the caption <i>caption</i> and the text <i>text</i>. The dialog may have up to three buttons. Each of the buttons, <i>button0</i>, <i>button1</i> and <i>button2</i> may be set to one of the following values:</p>
430
<li><a href="qmessagebox.html#Button-enum">QMessageBox::NoButton</a></li>
431
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Ok</a></li>
432
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Cancel</a></li>
433
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Yes</a></li>
434
<li><a href="qmessagebox.html#Button-enum">QMessageBox::No</a></li>
435
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Abort</a></li>
436
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Retry</a></li>
437
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Ignore</a></li>
438
<li><a href="qmessagebox.html#Button-enum">QMessageBox::YesAll</a></li>
439
<li><a href="qmessagebox.html#Button-enum">QMessageBox::NoAll</a></li>
441
<p>If you don't want all three buttons, set the last button, or last two buttons to <a href="qmessagebox.html#Button-enum">QMessageBox::NoButton</a>.</p>
442
<p>One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one button can be OR-ed with <tt>QMessageBox::Escape</tt>.</p>
443
<p>Returns the identity (<a href="qmessagebox.html#Button-enum">QMessageBox::Ok</a>, or <a href="qmessagebox.html#Button-enum">QMessageBox::No</a>, etc.) of the button that was clicked.</p>
444
<p>If <i>parent</i> is 0, the message box becomes an application-global modal dialog box. If <i>parent</i> is a widget, the message box becomes modal relative to <i>parent</i>.</p>
445
<p>See also <a href="qmessagebox.html#question">question</a>(), <a href="qmessagebox.html#warning">warning</a>(), and <a href="qmessagebox.html#critical">critical</a>().</p>
446
<h3 class="fn"><a name="information-2"></a>int QMessageBox::information ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> & <i>caption</i>, const <a href="qstring.html">QString</a> & <i>text</i>, const <a href="qstring.html">QString</a> & <i>button0Text</i> = QString(), const <a href="qstring.html">QString</a> & <i>button1Text</i> = QString(), const <a href="qstring.html">QString</a> & <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 ) <tt> [static]</tt></h3>
447
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
448
<p>Displays an information message box with caption <i>caption</i>, text <i>text</i> and one, two or three buttons. Returns the index of the button that was clicked (0, 1 or 2).</p>
449
<p><i>button0Text</i> is the text of the first button, and is optional. If <i>button0Text</i> is not supplied, "OK" (translated) will be used. <i>button1Text</i> is the text of the second button, and is optional. <i>button2Text</i> is the text of the third button, and is optional. <i>defaultButtonNumber</i> (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). <i>escapeButtonNumber</i> 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.</p>
450
<p>If <i>parent</i> is 0, the message box becomes an application-global modal dialog box. If <i>parent</i> is a widget, the message box becomes modal relative to <i>parent</i>.</p>
451
<p>Note: If you do not specify an Escape button then if the Escape button is pressed then -1 will be returned. It is suggested that you specify an Escape button to prevent this from happening.</p>
452
<p>See also <a href="qmessagebox.html#question">question</a>(), <a href="qmessagebox.html#warning">warning</a>(), and <a href="qmessagebox.html#critical">critical</a>().</p>
453
<h3 class="fn"><a name="question"></a>int QMessageBox::question ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> & <i>caption</i>, const <a href="qstring.html">QString</a> & <i>text</i>, int <i>button0</i>, int <i>button1</i> = 0, int <i>button2</i> = 0 ) <tt> [static]</tt></h3>
454
<p>Opens a question message box with the caption <i>caption</i> and the text <i>text</i>. The dialog may have up to three buttons. Each of the buttons, <i>button0</i>, <i>button1</i> and <i>button2</i> may be set to one of the following values:</p>
456
<li><a href="qmessagebox.html#Button-enum">QMessageBox::NoButton</a></li>
457
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Ok</a></li>
458
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Cancel</a></li>
459
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Yes</a></li>
460
<li><a href="qmessagebox.html#Button-enum">QMessageBox::No</a></li>
461
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Abort</a></li>
462
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Retry</a></li>
463
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Ignore</a></li>
464
<li><a href="qmessagebox.html#Button-enum">QMessageBox::YesAll</a></li>
465
<li><a href="qmessagebox.html#Button-enum">QMessageBox::NoAll</a></li>
467
<p>If you don't want all three buttons, set the last button, or last two buttons to <a href="qmessagebox.html#Button-enum">QMessageBox::NoButton</a>.</p>
468
<p>One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one button can be OR-ed with <tt>QMessageBox::Escape</tt>.</p>
469
<p>Returns the identity (<a href="qmessagebox.html#Button-enum">QMessageBox::Yes</a>, or <a href="qmessagebox.html#Button-enum">QMessageBox::No</a>, etc.) of the button that was clicked.</p>
470
<p>If <i>parent</i> is 0, the message box becomes an application-global modal dialog box. If <i>parent</i> is a widget, the message box becomes modal relative to <i>parent</i>.</p>
471
<p>See also <a href="qmessagebox.html#information">information</a>(), <a href="qmessagebox.html#warning">warning</a>(), and <a href="qmessagebox.html#critical">critical</a>().</p>
472
<h3 class="fn"><a name="question-2"></a>int QMessageBox::question ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> & <i>caption</i>, const <a href="qstring.html">QString</a> & <i>text</i>, const <a href="qstring.html">QString</a> & <i>button0Text</i> = QString(), const <a href="qstring.html">QString</a> & <i>button1Text</i> = QString(), const <a href="qstring.html">QString</a> & <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 ) <tt> [static]</tt></h3>
473
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
474
<p>Displays a question message box with caption <i>caption</i>, text <i>text</i> and one, two or three buttons. Returns the index of the button that was clicked (0, 1 or 2).</p>
475
<p><i>button0Text</i> is the text of the first button, and is optional. If <i>button0Text</i> is not supplied, "OK" (translated) will be used. <i>button1Text</i> is the text of the second button, and is optional. <i>button2Text</i> is the text of the third button, and is optional. <i>defaultButtonNumber</i> (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). <i>escapeButtonNumber</i> 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.</p>
476
<p>If <i>parent</i> is 0, the message box becomes an application-global modal dialog box. If <i>parent</i> is a widget, the message box becomes modal relative to <i>parent</i>.</p>
477
<p>Note: If you do not specify an Escape button then if the Escape button is pressed then -1 will be returned. It is suggested that you specify an Escape button to prevent this from happening.</p>
478
<p>See also <a href="qmessagebox.html#information">information</a>(), <a href="qmessagebox.html#warning">warning</a>(), and <a href="qmessagebox.html#critical">critical</a>().</p>
479
<h3 class="fn"><a name="setButtonText"></a>void QMessageBox::setButtonText ( int <i>button</i>, const <a href="qstring.html">QString</a> & <i>text</i> )</h3>
480
<p>Sets the text of the message box button <i>button</i> to <i>text</i>. Setting the text of a button that is not in the message box is silently ignored.</p>
481
<p>See also <a href="qmessagebox.html#buttonText">buttonText</a>().</p>
482
<h3 class="fn"><a name="standardIcon-2"></a><a href="qpixmap.html">QPixmap</a> QMessageBox::standardIcon ( <a href="qmessagebox.html#Icon-enum">Icon</a> <i>icon</i> ) <tt> [static]</tt></h3>
483
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
484
<p>Returns the pixmap used for a standard icon. This allows the pixmaps to be used in more complex message boxes. <i>icon</i> specifies the required icon, e.g. <a href="qmessagebox.html#Icon-enum">QMessageBox::Question</a>, <a href="qmessagebox.html#Icon-enum">QMessageBox::Information</a>, <a href="qmessagebox.html#Icon-enum">QMessageBox::Warning</a> or <a href="qmessagebox.html#Icon-enum">QMessageBox::Critical</a>.</p>
485
<h3 class="fn"><a name="warning"></a>int QMessageBox::warning ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> & <i>caption</i>, const <a href="qstring.html">QString</a> & <i>text</i>, int <i>button0</i>, int <i>button1</i>, int <i>button2</i> = 0 ) <tt> [static]</tt></h3>
486
<p>Opens a warning message box with the caption <i>caption</i> and the text <i>text</i>. The dialog may have up to three buttons. Each of the button parameters, <i>button0</i>, <i>button1</i> and <i>button2</i> may be set to one of the following values:</p>
488
<li><a href="qmessagebox.html#Button-enum">QMessageBox::NoButton</a></li>
489
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Ok</a></li>
490
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Cancel</a></li>
491
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Yes</a></li>
492
<li><a href="qmessagebox.html#Button-enum">QMessageBox::No</a></li>
493
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Abort</a></li>
494
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Retry</a></li>
495
<li><a href="qmessagebox.html#Button-enum">QMessageBox::Ignore</a></li>
496
<li><a href="qmessagebox.html#Button-enum">QMessageBox::YesAll</a></li>
497
<li><a href="qmessagebox.html#Button-enum">QMessageBox::NoAll</a></li>
499
<p>If you don't want all three buttons, set the last button, or last two buttons to <a href="qmessagebox.html#Button-enum">QMessageBox::NoButton</a>.</p>
500
<p>One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one button can be OR-ed with <tt>QMessageBox::Escape</tt>.</p>
501
<p>Returns the identity (<a href="qmessagebox.html#Button-enum">QMessageBox::Ok</a>, or <a href="qmessagebox.html#Button-enum">QMessageBox::No</a>, etc.) of the button that was clicked.</p>
502
<p>If <i>parent</i> is 0, the message box becomes an application-global modal dialog box. If <i>parent</i> is a widget, the message box becomes modal relative to <i>parent</i>.</p>
503
<p>See also <a href="qmessagebox.html#information">information</a>(), <a href="qmessagebox.html#question">question</a>(), and <a href="qmessagebox.html#critical">critical</a>().</p>
504
<h3 class="fn"><a name="warning-2"></a>int QMessageBox::warning ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> & <i>caption</i>, const <a href="qstring.html">QString</a> & <i>text</i>, const <a href="qstring.html">QString</a> & <i>button0Text</i> = QString(), const <a href="qstring.html">QString</a> & <i>button1Text</i> = QString(), const <a href="qstring.html">QString</a> & <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 ) <tt> [static]</tt></h3>
505
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
506
<p>Displays a warning message box with a caption, a text, and 1, 2 or 3 buttons. Returns the number of the button that was clicked (0, 1, or 2).</p>
507
<p><i>button0Text</i> is the text of the first button, and is optional. If <i>button0Text</i> is not supplied, "OK" (translated) will be used. <i>button1Text</i> is the text of the second button, and is optional, and <i>button2Text</i> is the text of the third button, and is optional. <i>defaultButtonNumber</i> (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). <i>escapeButtonNumber</i> 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.</p>
508
<p>If <i>parent</i> is 0, the message box becomes an application-global modal dialog box. If <i>parent</i> is a widget, the message box becomes modal relative to <i>parent</i>.</p>
509
<p>Note: If you do not specify an Escape button then if the Escape button is pressed then -1 will be returned. It is suggested that you specify an Escape button to prevent this from happening.</p>
510
<p>See also <a href="qmessagebox.html#information">information</a>(), <a href="qmessagebox.html#question">question</a>(), and <a href="qmessagebox.html#critical">critical</a>().</p>
512
<h2>Macro Documentation</h2>
513
<h3 class="fn"><a name="QT_REQUIRE_VERSION"></a>QT_REQUIRE_VERSION ( int <i>argc</i>, char ** <i>argv</i>, const char * <i>version</i> )</h3>
514
<p>This macro can be used to ensure that the application is run against a recent enough version of Qt. This is especially useful if your application depends on a specific bug fix introduced in a bug-fix release (e.g., 4.0.2).</p>
515
<p>The <i>argc</i> and <i>argv</i> parameters are the <tt>main()</tt> function's <tt>argc</tt> and <tt>argv</tt> parameters. The <i>version</i> parameter is a string literal that specifies which version of Qt the application requires (e.g., "4.0.2").</p>
517
<pre> #include <QApplication>
518
#include <QMessageBox>
520
int main(int argc, char *argv[])
522
QT_REQUIRE_VERSION(argc, argv, "4.0.2")
524
QApplication app(argc, argv);
528
<p /><address><hr /><div align="center">
529
<table width="100%" cellspacing="0" border="0"><tr class="address">
530
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
531
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
532
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
533
</tr></table></div></address></body>