~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qmessagebox.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
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 -->
 
6
<head>
 
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>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
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">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <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 &lt;QMessageBox&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<p>Inherits <a href="qdialog.html">QDialog</a>.</p>
 
24
<ul>
 
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>
 
27
</ul>
 
28
<a name="public-types"></a>
 
29
<h3>Public Types</h3>
 
30
<ul>
 
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>
 
33
</ul>
 
34
<a name="properties"></a>
 
35
<h3>Properties</h3>
 
36
<ul>
 
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>
 
41
</ul>
 
42
<ul>
 
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>
 
46
</ul>
 
47
<a name="public-functions"></a>
 
48
<h3>Public Functions</h3>
 
49
<ul>
 
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 &amp; <i>caption</i>, const QString &amp; <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 &amp; <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 &amp; )</li>
 
59
<li><div class="fn"/>void <b><a href="qmessagebox.html#text-prop">setText</a></b> ( const QString &amp; )</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>
 
63
</ul>
 
64
<ul>
 
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>
 
69
</ul>
 
70
<a name="static-public-members"></a>
 
71
<h3>Static Public Members</h3>
 
72
<ul>
 
73
<li><div class="fn"/>void <b><a href="qmessagebox.html#about">about</a></b> ( QWidget * <i>parent</i>, const QString &amp; <i>caption</i>, const QString &amp; <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 &amp; <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 &amp; <i>caption</i>, const QString &amp; <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 &amp; <i>caption</i>, const QString &amp; <i>text</i>, const QString &amp; <i>button0Text</i> = QString(), const QString &amp; <i>button1Text</i> = QString(), const QString &amp; <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 &amp; <i>caption</i>, const QString &amp; <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 &amp; <i>caption</i>, const QString &amp; <i>text</i>, const QString &amp; <i>button0Text</i> = QString(), const QString &amp; <i>button1Text</i> = QString(), const QString &amp; <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 &amp; <i>caption</i>, const QString &amp; <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 &amp; <i>caption</i>, const QString &amp; <i>text</i>, const QString &amp; <i>button0Text</i> = QString(), const QString &amp; <i>button1Text</i> = QString(), const QString &amp; <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 &amp; <i>caption</i>, const QString &amp; <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 &amp; <i>caption</i>, const QString &amp; <i>text</i>, const QString &amp; <i>button0Text</i> = QString(), const QString &amp; <i>button1Text</i> = QString(), const QString &amp; <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 )</li>
 
84
</ul>
 
85
<ul>
 
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>
 
88
</ul>
 
89
<a name="macros"></a>
 
90
<h3>Macros</h3>
 
91
<ul>
 
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>
 
93
</ul>
 
94
<h3>Additional Inherited Members</h3>
 
95
<ul>
 
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>
 
103
</ul>
 
104
<a name="details"></a>
 
105
<hr />
 
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>
 
110
<p>Severity is</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>
 
116
</table>
 
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>
 
120
<p>Examples:</p>
 
121
<p>If a program is unable to find a supporting file, but can do perfectly well without it:</p>
 
122
<pre>&nbsp;   QMessageBox::information(this, &quot;Application name&quot;,
 
123
    &quot;Unable to find the user preferences file.\n&quot;
 
124
    &quot;The factory default will be used instead.&quot;);</pre>
 
125
<p><a href="qmessagebox.html#question">question</a>() is useful for simple yes/no questions:</p>
 
126
<pre>&nbsp;       if (QFile::exists(filename) &amp;&amp;
 
127
            QMessageBox::question(
 
128
                this,
 
129
                tr(&quot;Overwrite File? -- Application Name&quot;),
 
130
                tr(&quot;A file called %1 already exists.&quot;
 
131
                   &quot;Do you want to overwrite it?&quot;)
 
132
                .arg(filename),
 
133
                tr(&quot;&amp;Yes&quot;), tr(&quot;&amp;No&quot;),
 
134
                QString(), 0, 1))
 
135
            return false;</pre>
 
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>&nbsp;       switch(QMessageBox::warning(this, &quot;Application name&quot;,
 
138
                                    &quot;Could not connect to the &lt;mumble&gt; server.\n&quot;
 
139
                                    &quot;This program can't function correctly &quot;
 
140
                                    &quot;without the server.\n\n&quot;,
 
141
                                    &quot;Retry&quot;,
 
142
                                    &quot;Quit&quot;, 0, 0, 1)) {
 
143
        case 0: // The user clicked the Retry again button or pressed Enter
 
144
            // try again
 
145
            break;
 
146
        case 1: // The user clicked the Quit or pressed Escape
 
147
            // exit
 
148
            break;
 
149
        }</pre>
 
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>&nbsp;       switch(QMessageBox::information(this, &quot;Application name here&quot;,
 
155
                                        &quot;The document contains unsaved changes\n&quot;
 
156
                                        &quot;Do you want to save the changes before exiting?&quot;,
 
157
                                        &quot;&amp;Save&quot;, &quot;&amp;Discard&quot;, &quot;Cancel&quot;,
 
158
                                        0,      // Enter == button 0
 
159
                                        2)) { // Escape == button 2
 
160
        case 0: // Save clicked or Alt+S pressed or Enter pressed.
 
161
            // save
 
162
            break;
 
163
        case 1: // Discard clicked or Alt+D pressed
 
164
            // don't save but exit
 
165
            break;
 
166
        case 2: // Cancel clicked or Escape pressed
 
167
            // don't exit
 
168
            break;
 
169
        }</pre>
 
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>&nbsp;       switch(QMessageBox::warning(this, &quot;Application name here&quot;,
 
173
                                    &quot;Could not save the user preferences,\n&quot;
 
174
                                    &quot;because the disk is full. You can delete\n&quot;
 
175
                                    &quot;some files and press Retry, or you can\n&quot;
 
176
                                    &quot;abort the Save Preferences operation.&quot;,
 
177
                                    QMessageBox::Retry | QMessageBox::Default,
 
178
                                    QMessageBox::Abort | QMessageBox::Escape)) {
 
179
        case QMessageBox::Retry: // Retry clicked or Enter pressed
 
180
            // try again
 
181
            break;
 
182
        case QMessageBox::Abort: // Abort clicked or Escape pressed
 
183
            // abort
 
184
            break;
 
185
        }</pre>
 
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>&nbsp;       QMessageBox::critical(0, &quot;Application name here&quot;,
 
188
                              QString(&quot;An internal error occurred. Please &quot;) +
 
189
                              &quot;call technical support at 1234-56789 and report\n&quot;+
 
190
                              &quot;these numbers:\n\n&quot; + errorDetails +
 
191
                              &quot;\n\nApplication will now exit.&quot;);</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>&nbsp;       QMessageBox::about(this, &quot;About &lt;Application&gt;&quot;,
 
195
                           &quot;&lt;Application&gt; is a &lt;one-paragraph blurb&gt;\n\n&quot;
 
196
                           &quot;Copyright 1991-2003 Such-and-such. &quot;
 
197
                           &quot;&lt;License words here.&gt;\n\n&quot;
 
198
                           &quot;For technical support, call 1234-56789 or see\n&quot;
 
199
                           &quot;http://www.such-and-such.com/Application/\n&quot;);</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 &quot;About Qt&quot; 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>&nbsp;           QMessageBox mb(&quot;Application name here&quot;,
 
204
                           &quot;Saving the file will overwrite the original file on the disk.\n&quot;
 
205
                           &quot;Do you really want to save?&quot;,
 
206
                           QMessageBox::Information,
 
207
                           QMessageBox::Yes | QMessageBox::Default,
 
208
                           QMessageBox::No,
 
209
                           QMessageBox::Cancel | QMessageBox::Escape);
 
210
            mb.setButtonText(QMessageBox::Yes, &quot;Save&quot;);
 
211
            mb.setButtonText(QMessageBox::No, &quot;Discard&quot;);
 
212
            switch(mb.exec()) {
 
213
            case QMessageBox::Yes:
 
214
                // save and exit
 
215
                break;
 
216
            case QMessageBox::No:
 
217
                // exit without saving
 
218
                break;
 
219
            case QMessageBox::Cancel:
 
220
                // don't save and don't exit
 
221
                break;
 
222
            }</pre>
 
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>
 
225
<ul>
 
226
<li>Ok - the default for single-button message boxes</li>
 
227
<li>Cancel - note that this is <i>not</i> automatically Escape</li>
 
228
<li>Yes</li>
 
229
<li>No</li>
 
230
<li>Abort</li>
 
231
<li>Retry</li>
 
232
<li>Ignore</li>
 
233
<li><a href="qmessagebox.html#Button-enum">YesAll</a></li>
 
234
<li><a href="qmessagebox.html#Button-enum">NoAll</a></li>
 
235
</ul>
 
236
<p>Button types can be combined with two modifiers by using OR, '|':</p>
 
237
<ul>
 
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>
 
240
</ul>
 
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>
 
247
<hr />
 
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 &quot;Ok&quot; 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 &quot;Cancel&quot; 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 &quot;Yes&quot; 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 &quot;No&quot; 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 &quot;Abort&quot; 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 &quot;Retry&quot; 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 &quot;Ignore&quot; 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 &quot;Yes to all&quot; 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 &quot;No to all&quot; button.</td></tr>
 
262
</table>
 
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>
 
268
</table>
 
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>
 
274
</table>
 
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>
 
279
</table>
 
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>
 
289
</table>
 
290
<hr />
 
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>
 
295
<ul>
 
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>
 
301
</ul>
 
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>
 
304
<ul>
 
305
<li><div class="fn"/><b>Icon icon () const</b></li>
 
306
<li><div class="fn"/><b>void setIcon ( Icon )</b></li>
 
307
</ul>
 
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>
 
313
<ul>
 
314
<li><div class="fn"/><b>QPixmap iconPixmap () const</b></li>
 
315
<li><div class="fn"/><b>void setIconPixmap ( const QPixmap &amp; )</b></li>
 
316
</ul>
 
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>
 
323
<ul>
 
324
<li><div class="fn"/><b>QString text () const</b></li>
 
325
<li><div class="fn"/><b>void setText ( const QString &amp; )</b></li>
 
326
</ul>
 
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>
 
333
<ul>
 
334
<li><div class="fn"/><b>Qt::TextFormat textFormat () const</b></li>
 
335
<li><div class="fn"/><b>void setTextFormat ( Qt::TextFormat )</b></li>
 
336
</ul>
 
337
<p>See also <a href="qmessagebox.html#text-prop">setText</a>().</p>
 
338
<hr />
 
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 &quot;OK&quot;.</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> &amp; <i>caption</i>, const <a href="qstring.html">QString</a> &amp; <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>
 
347
<ul>
 
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>
 
353
</ul>
 
354
<p>Each button, <i>button0</i>, <i>button1</i> and <i>button2</i>, can have one of the following values:</p>
 
355
<ul>
 
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>
 
366
</ul>
 
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>&nbsp;           QMessageBox mb(&quot;Application Name&quot;,
 
371
                           &quot;Hardware failure.\n\nDisk error detected\nDo you want to stop?&quot;,
 
372
                           QMessageBox::Question,
 
373
                           QMessageBox::Yes | QMessageBox::Default,
 
374
                           QMessageBox::No | QMessageBox::Escape,
 
375
                           QMessageBox::NoButton);
 
376
            if (mb.exec() == QMessageBox::No) {
 
377
                // try again</pre>
 
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> &amp; <i>caption</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i> )&nbsp;&nbsp;<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>
 
386
<ol type="1">
 
387
<li>It prefers <a href="qwidget.html#windowIcon-prop">parent-&gt;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>
 
391
</ol>
 
392
<p>The about box has a single button labelled &quot;OK&quot;.</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> &amp; <i>caption</i> = QString() )&nbsp;&nbsp;<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> &amp; <i>caption</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, int <i>button0</i>, int <i>button1</i>, int <i>button2</i> = 0 )&nbsp;&nbsp;<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>
 
404
<ul>
 
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>
 
415
</ul>
 
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> &amp; <i>caption</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, const <a href="qstring.html">QString</a> &amp; <i>button0Text</i> = QString(), const <a href="qstring.html">QString</a> &amp; <i>button1Text</i> = QString(), const <a href="qstring.html">QString</a> &amp; <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 )&nbsp;&nbsp;<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, &quot;OK&quot; (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> &amp; <i>caption</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, int <i>button0</i>, int <i>button1</i> = 0, int <i>button2</i> = 0 )&nbsp;&nbsp;<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>
 
429
<ul>
 
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>
 
440
</ul>
 
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> &amp; <i>caption</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, const <a href="qstring.html">QString</a> &amp; <i>button0Text</i> = QString(), const <a href="qstring.html">QString</a> &amp; <i>button1Text</i> = QString(), const <a href="qstring.html">QString</a> &amp; <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 )&nbsp;&nbsp;<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, &quot;OK&quot; (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> &amp; <i>caption</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, int <i>button0</i>, int <i>button1</i> = 0, int <i>button2</i> = 0 )&nbsp;&nbsp;<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>
 
455
<ul>
 
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>
 
466
</ul>
 
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> &amp; <i>caption</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, const <a href="qstring.html">QString</a> &amp; <i>button0Text</i> = QString(), const <a href="qstring.html">QString</a> &amp; <i>button1Text</i> = QString(), const <a href="qstring.html">QString</a> &amp; <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 )&nbsp;&nbsp;<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, &quot;OK&quot; (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> &amp; <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> )&nbsp;&nbsp;<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> &amp; <i>caption</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, int <i>button0</i>, int <i>button1</i>, int <i>button2</i> = 0 )&nbsp;&nbsp;<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>
 
487
<ul>
 
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>
 
498
</ul>
 
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> &amp; <i>caption</i>, const <a href="qstring.html">QString</a> &amp; <i>text</i>, const <a href="qstring.html">QString</a> &amp; <i>button0Text</i> = QString(), const <a href="qstring.html">QString</a> &amp; <i>button1Text</i> = QString(), const <a href="qstring.html">QString</a> &amp; <i>button2Text</i> = QString(), int <i>defaultButtonNumber</i> = 0, int <i>escapeButtonNumber</i> = -1 )&nbsp;&nbsp;<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, &quot;OK&quot; (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>
 
511
<hr />
 
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., &quot;4.0.2&quot;).</p>
 
516
<p>Example:</p>
 
517
<pre>&nbsp;   #include &lt;QApplication&gt;
 
518
    #include &lt;QMessageBox&gt;
 
519
 
 
520
    int main(int argc, char *argv[])
 
521
    {
 
522
        QT_REQUIRE_VERSION(argc, argv, &quot;4.0.2&quot;)
 
523
 
 
524
        QApplication app(argc, argv);
 
525
        ...
 
526
        return app.exec();
 
527
    }</pre>
 
528
<p /><address><hr /><div align="center">
 
529
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
530
<td width="30%">Copyright &copy; 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>
 
534
</html>