File: qmessagebox.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (489 lines) | stat: -rw-r--r-- 48,997 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QMessageBox Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QMessageBox Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons. <a href="#details">More...</a></p>
<p>Inherits <a href="qdialog.html">QDialog</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qmessagebox.html#Button-enum">Button</a></b> { NoButton, Ok, Cancel, Yes, ..., FlagMask }</li><li><div class="fn" />enum <b><a href="qmessagebox.html#Icon-enum">Icon</a></b> { NoIcon, Information, Warning, Critical, Question }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qmessagebox.html#QMessageBox">__init__</a></b> (<i>self</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qmessagebox.html#QMessageBox-2">__init__</a></b> (<i>self</i>, QString&#160;<i>caption</i>, QString&#160;<i>text</i>, Icon&#160;<i>icon</i>, int&#160;<i>button0</i>, int&#160;<i>button1</i>, int&#160;<i>button2</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None, Qt.WindowFlags&#160;<i>f</i>&#160;=&#160;Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint)</li><li><div class="fn" />QString <b><a href="qmessagebox.html#buttonText">buttonText</a></b> (<i>self</i>, int&#160;<i>button</i>)</li><li><div class="fn" /><b><a href="qmessagebox.html#changeEvent">changeEvent</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" /><b><a href="qmessagebox.html#closeEvent">closeEvent</a></b> (<i>self</i>, QCloseEvent)</li><li><div class="fn" />Icon <b><a href="qmessagebox.html#icon">icon</a></b> (<i>self</i>)</li><li><div class="fn" />QPixmap <b><a href="qmessagebox.html#iconPixmap">iconPixmap</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmessagebox.html#keyPressEvent">keyPressEvent</a></b> (<i>self</i>, QKeyEvent)</li><li><div class="fn" /><b><a href="qmessagebox.html#resizeEvent">resizeEvent</a></b> (<i>self</i>, QResizeEvent)</li><li><div class="fn" /><b><a href="qmessagebox.html#setButtonText">setButtonText</a></b> (<i>self</i>, int&#160;<i>button</i>, QString)</li><li><div class="fn" /><b><a href="qmessagebox.html#setIcon">setIcon</a></b> (<i>self</i>, Icon)</li><li><div class="fn" /><b><a href="qmessagebox.html#setIconPixmap">setIconPixmap</a></b> (<i>self</i>, QPixmap)</li><li><div class="fn" /><b><a href="qmessagebox.html#setText">setText</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qmessagebox.html#setTextFormat">setTextFormat</a></b> (<i>self</i>, Qt.TextFormat)</li><li><div class="fn" /><b><a href="qmessagebox.html#showEvent">showEvent</a></b> (<i>self</i>, QShowEvent)</li><li><div class="fn" />QSize <b><a href="qmessagebox.html#sizeHint">sizeHint</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qmessagebox.html#text">text</a></b> (<i>self</i>)</li><li><div class="fn" />Qt.TextFormat <b><a href="qmessagebox.html#textFormat">textFormat</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" /><b><a href="qmessagebox.html#about">about</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>caption</i>, QString&#160;<i>text</i>)</li><li><div class="fn" /><b><a href="qmessagebox.html#aboutQt">aboutQt</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>caption</i>&#160;=&#160;QString())</li><li><div class="fn" />int <b><a href="qmessagebox.html#critical">critical</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>caption</i>, QString&#160;<i>text</i>, int&#160;<i>button0</i>, int&#160;<i>button1</i>, int&#160;<i>button2</i>&#160;=&#160;0)</li><li><div class="fn" />int <b><a href="qmessagebox.html#critical-2">critical</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>caption</i>, QString&#160;<i>text</i>, QString&#160;<i>button0Text</i>&#160;=&#160;QString(), QString&#160;<i>button1Text</i>&#160;=&#160;QString(), QString&#160;<i>button2Text</i>&#160;=&#160;QString(), int&#160;<i>defaultButtonNumber</i>&#160;=&#160;0, int&#160;<i>escapeButtonNumber</i>&#160;=&#160;-1)</li><li><div class="fn" />int <b><a href="qmessagebox.html#information">information</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>caption</i>, QString&#160;<i>text</i>, int&#160;<i>button0</i>, int&#160;<i>button1</i>&#160;=&#160;0, int&#160;<i>button2</i>&#160;=&#160;0)</li><li><div class="fn" />int <b><a href="qmessagebox.html#information-2">information</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>caption</i>, QString&#160;<i>text</i>, QString&#160;<i>button0Text</i>&#160;=&#160;QString(), QString&#160;<i>button1Text</i>&#160;=&#160;QString(), QString&#160;<i>button2Text</i>&#160;=&#160;QString(), int&#160;<i>defaultButtonNumber</i>&#160;=&#160;0, int&#160;<i>escapeButtonNumber</i>&#160;=&#160;-1)</li><li><div class="fn" />int <b><a href="qmessagebox.html#question">question</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>caption</i>, QString&#160;<i>text</i>, int&#160;<i>button0</i>, int&#160;<i>button1</i>&#160;=&#160;0, int&#160;<i>button2</i>&#160;=&#160;0)</li><li><div class="fn" />int <b><a href="qmessagebox.html#question-2">question</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>caption</i>, QString&#160;<i>text</i>, QString&#160;<i>button0Text</i>&#160;=&#160;QString(), QString&#160;<i>button1Text</i>&#160;=&#160;QString(), QString&#160;<i>button2Text</i>&#160;=&#160;QString(), int&#160;<i>defaultButtonNumber</i>&#160;=&#160;0, int&#160;<i>escapeButtonNumber</i>&#160;=&#160;-1)</li><li><div class="fn" />QPixmap <b><a href="qmessagebox.html#standardIcon">standardIcon</a></b> (Icon&#160;<i>icon</i>)</li><li><div class="fn" />int <b><a href="qmessagebox.html#warning">warning</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>caption</i>, QString&#160;<i>text</i>, int&#160;<i>button0</i>, int&#160;<i>button1</i>, int&#160;<i>button2</i>&#160;=&#160;0)</li><li><div class="fn" />int <b><a href="qmessagebox.html#warning-2">warning</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>caption</i>, QString&#160;<i>text</i>, QString&#160;<i>button0Text</i>&#160;=&#160;QString(), QString&#160;<i>button1Text</i>&#160;=&#160;QString(), QString&#160;<i>button2Text</i>&#160;=&#160;QString(), int&#160;<i>defaultButtonNumber</i>&#160;=&#160;0, int&#160;<i>escapeButtonNumber</i>&#160;=&#160;-1)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons.</p>
<p>Message boxes are used to provide informative messages and to ask simple questions.</p>
<p>QMessageBox provides a range of different messages, arranged roughly along two axes: severity and complexity.</p>
<p>Severity is</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#F0F0F0" valign="top">
<td>
<p align="center"><img src="images/qmessagebox-quest.png" /></p>
</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>
<tr bgcolor="#E0E0E0" valign="top">
<td>
<p align="center"><img src="images/qmessagebox-info.png" /></p>
</td>
<td>Information</td>
<td>For message boxes that are part of normal operation.</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td>
<p align="center"><img src="images/qmessagebox-warn.png" /></p>
</td>
<td>Warning</td>
<td>For message boxes that tell the user about unusual errors.</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td>
<p align="center"><img src="images/qmessagebox-crit.png" /></p>
</td>
<td>Critical</td>
<td>For message boxes that tell the user about critical errors.</td>
</tr>
</table>
<br />
<br />
<p>The message box has a different icon for each of the severity levels.</p>
<p>Complexity is one button (OK) for simple messages, or two or even three buttons for questions.</p>
<p>There are static functions for the most common cases.</p>
<p>Examples:</p>
<p>If a program is unable to find a supporting file, but can do perfectly well without it:</p>
<pre>
    QMessageBox.information(this, "Application name",
    "Unable to find the user preferences file.\n"
    "The factory default will be used instead.");
</pre>
<p><a href="qmessagebox.html#question">question</a>() is useful for simple yes/no questions:</p>
<pre>
        if (QFile.exists(filename) &amp;&amp;
            QMessageBox.question(
                this,
                tr("Overwrite File? -- Application Name"),
                tr("A file called %1 already exists."
                   "Do you want to overwrite it?")
                .arg(filename),
                tr("&amp;Yes"), tr("&amp;No"),
                QString(), 0, 1))
            return false;
</pre>
<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>
<pre>
        switch(QMessageBox.warning(this, "Application name",
                                    "Could not connect to the &lt;mumble&gt; server.\n"
                                    "This program can't function correctly "
                                    "without the server.\n\n",
                                    "Retry",
                                    "Quit", 0, 0, 1)) {
        case 0: // The user clicked the Retry again button or pressed Enter
            // try again
            break;
        case 1: // The user clicked the Quit or pressed Escape
            // exit
            break;
        }
</pre>
<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>
<p>Note that the Microsoft Windows User Interface Guidelines recommend using the application name as the window's caption.</p>
<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>
<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>
<pre>
        switch(QMessageBox.information(this, "Application name here",
                                        "The document contains unsaved changes\n"
                                        "Do you want to save the changes before exiting?",
                                        "&amp;Save", "&amp;Discard", "Cancel",
                                        0,      // Enter == button 0
                                        2)) { // Escape == button 2
        case 0: // Save clicked or Alt+S pressed or Enter pressed.
            // save
            break;
        case 1: // Discard clicked or Alt+D pressed
            // don't save but exit
            break;
        case 2: // Cancel clicked or Escape pressed
            // don't exit
            break;
        }
</pre>
<p>The Escape button cancels the entire exit operation, and pressing Enter causes the changes to be saved before the exit occurs.</p>
<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>
<pre>
        switch(QMessageBox.warning(this, "Application name here",
                                    "Could not save the user preferences,\n"
                                    "because the disk is full. You can delete\n"
                                    "some files and press Retry, or you can\n"
                                    "abort the Save Preferences operation.",
                                    QMessageBox.Retry | QMessageBox.Default,
                                    QMessageBox.Abort | QMessageBox.Escape)) {
        case QMessageBox.Retry: // Retry clicked or Enter pressed
            // try again
            break;
        case QMessageBox.Abort: // Abort clicked or Escape pressed
            // abort
            break;
        }
</pre>
<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>
<pre>
        QMessageBox.critical(0, "Application name here",
                              QString("An internal error occurred. Please ") +
                              "call technical support at 1234-56789 and report\n"+
                              "these numbers:\n\n" + errorDetails +
                              "\n\nApplication will now exit.");
</pre>
<p>In this example an OK button is displayed.</p>
<p>QMessageBox provides a very simple About box which displays an appropriate icon and the string you provide:</p>
<pre>
        QMessageBox.about(this, "About &lt;Application&gt;",
                           "&lt;Application&gt; is a &lt;one-paragraph blurb&gt;\n\n"
                           "Copyright 1991-2003 Such-and-such. "
                           "&lt;License words here.&gt;\n\n"
                           "For technical support, call 1234-56789 or see\n"
                           "http://www.such-and-such.com/Application/\n");
</pre>
<p>See <a href="qmessagebox.html#about">about</a>() for more information.</p>
<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>
<p>If none of the standard message boxes is suitable, you can create a QMessageBox from scratch and use custom button texts:</p>
<pre>
            QMessageBox mb("Application name here",
                           "Saving the file will overwrite the original file on the disk.\n"
                           "Do you really want to save?",
                           QMessageBox.Information,
                           QMessageBox.Yes | QMessageBox.Default,
                           QMessageBox.No,
                           QMessageBox.Cancel | QMessageBox.Escape);
            mb.setButtonText(QMessageBox.Yes, "Save");
            mb.setButtonText(QMessageBox.No, "Discard");
            switch(mb.exec()) {
            case QMessageBox.Yes:
                // save and exit
                break;
            case QMessageBox.No:
                // exit without saving
                break;
            case QMessageBox.Cancel:
                // don't save and don't exit
                break;
            }
</pre>
<p>QMessageBox defines two enum types: Icon and an unnamed button type. Icon defines the <a href="qmessagebox.html#Icon-enum">Question</a>, <a href="qmessagebox.html#Icon-enum">Information</a>, <a href="qmessagebox.html#Icon-enum">Warning</a>, and <a href="qmessagebox.html#Icon-enum">Critical</a> 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>
<p>The button types are:</p>
<ul>
<li>Ok - the default for single-button message boxes</li>
<li>Cancel - note that this is <i>not</i> automatically Escape</li>
<li>Yes</li>
<li>No</li>
<li>Abort</li>
<li>Retry</li>
<li>Ignore</li>
<li><a href="qmessagebox.html#Button-enum">YesAll</a></li>
<li><a href="qmessagebox.html#Button-enum">NoAll</a></li>
</ul>
<p>Button types can be combined with two modifiers by using OR, '|':</p>
<ul>
<li>Default - makes pressing Enter equivalent to clicking this button. Normally used with Ok, Yes or similar.</li>
<li>Escape - makes pressing Escape equivalent to clicking this button. Normally used with Abort, Cancel or similar.</li>
</ul>
<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>
<p><a href="qmessagebox.html#setButtonText">setButtonText</a>() and <a href="qmessagebox.html#buttonText">buttonText</a>() provide access to the buttons.</p>
<p>QMessageBox has no signals or slots.</p>
<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>
<p align="center"><img alt="A message box shown in the Plastique widget style." src="images/plastique-messagebox.png" /></p>
<p>See also <a href="qdialog.html">QDialog</a> and <a href="guibooks.html#fowler">GUI Design Handbook: Message Box</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="Button-enum" />QMessageBox.Button</h3><p>This enum describes the predefined buttons and button flags you can assign to a <a href="qmessagebox.html">QMessageBox</a>.</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
</table>
<br />
<br />
<p>The following values are flags that can be OR'ed with the button values.</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<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>
<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>
</table>
<br />
<br />
<p>The following values are masks that can be used to separate buttons from flags.</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<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>
<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>
</table>
<br />
<br />
<p>Finally, the last value is often used as a default value.</p>
<table border="1" cellpadding="2" cellspacing="1" width="40%">
<tr>
<th width="60%">Constant</th>
<th width="40%">Value</th>
</tr>
<tr>
<td valign="top"><tt>QMessageBox.NoButton</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
</tr>
</table>
<br />
<br />
<h3 class="fn"><a name="Icon-enum" />QMessageBox.Icon</h3><p>This enum has the following values:</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<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>
<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>
<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>
<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>
<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>
</table>
<br />
<br />
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QMessageBox" />QMessageBox.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a message box with no text and a button with the label "OK".</p>
<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>
<p>The <i>parent</i> argument is passed to the <a href="qdialog.html">QDialog</a> constructor.</p>
<h3 class="fn"><a name="QMessageBox-2" />QMessageBox.__init__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, <a href="qmessagebox.html#Icon-enum">Icon</a>&#160;<i>icon</i>, int&#160;<i>button0</i>, int&#160;<i>button1</i>, int&#160;<i>button2</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;None, <a href="qt-windowflags.html">Qt.WindowFlags</a>&#160;<i>f</i>&#160;=&#160;Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a message box with a <i>caption</i>, a <i>text</i>, an <i>icon</i>, and up to three buttons.</p>
<p>The <i>icon</i> must be one of the following:</p>
<ul>
<li><a href="qmessagebox.html#Icon-enum">QMessageBox.NoIcon</a></li>
<li><a href="qmessagebox.html#Icon-enum">QMessageBox.Question</a></li>
<li><a href="qmessagebox.html#Icon-enum">QMessageBox.Information</a></li>
<li><a href="qmessagebox.html#Icon-enum">QMessageBox.Warning</a></li>
<li><a href="qmessagebox.html#Icon-enum">QMessageBox.Critical</a></li>
</ul>
<p>Each button, <i>button0</i>, <i>button1</i> and <i>button2</i>, can have one of the following values:</p>
<ul>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.NoButton</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Ok</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Cancel</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Yes</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.No</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Abort</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Retry</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Ignore</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.YesAll</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.NoAll</a></li>
</ul>
<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>
<p>One of the buttons can be OR-ed with the <a href="qmessagebox.html#Button-enum">QMessageBox.Default</a> flag to make it the default button (clicked when Enter is pressed).</p>
<p>One of the buttons can be OR-ed with the <a href="qmessagebox.html#Button-enum">QMessageBox.Escape</a> flag to make it the cancel or close button (clicked when Escape is pressed).</p>
<pre>
            QMessageBox mb("Application Name",
                           "Hardware failure.\n\nDisk error detected\nDo you want to stop?",
                           QMessageBox.Question,
                           QMessageBox.Yes | QMessageBox.Default,
                           QMessageBox.No | QMessageBox.Escape,
                           QMessageBox.NoButton);
            if (mb.exec() == QMessageBox.No) {
                // try again
</pre>
<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>
<p>The <i>parent</i> and <i>f</i> arguments are passed to the <a href="qdialog.html">QDialog</a> constructor.</p>
<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>
<h3 class="fn"><a name="about" />QMessageBox.about (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>)</h3><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>
<p>about() looks for a suitable icon in four locations:</p>
<ol type="1">
<li>It prefers <a href="qwidget.html#windowIcon-prop">parent-&gt;icon()</a> if that exists.</li>
<li>If not, it tries the top-level widget containing <i>parent</i>.</li>
<li>If that fails, it tries the <a href="qapplication.html#activeWindow">active window.</a></li>
<li>As a last resort it uses the Information icon.</li>
</ol>
<p>The about box has a single button labelled "OK".</p>
<p>See also <a href="qwidget.html#windowIcon-prop">QWidget.windowIcon</a>() and <a href="qapplication.html#activeWindow">QApplication.activeWindow</a>().</p>
<h3 class="fn"><a name="aboutQt" />QMessageBox.aboutQt (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>&#160;=&#160;QString())</h3><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>
<p>This is useful for inclusion in the Help menu of an application. See the examples/menu/menu.cpp example.</p>
<p><a href="qapplication.html">QApplication</a> provides this functionality as a slot.</p>
<p>See also <a href="qapplication.html#aboutQt">QApplication.aboutQt</a>().</p>
<h3 class="fn"><a name="buttonText" /><a href="qstring.html">QString</a> QMessageBox.buttonText (<i>self</i>, int&#160;<i>button</i>)</h3><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>
<p>See also <a href="qmessagebox.html#setButtonText">setButtonText</a>().</p>
<h3 class="fn"><a name="changeEvent" />QMessageBox.changeEvent (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><h3 class="fn"><a name="closeEvent" />QMessageBox.closeEvent (<i>self</i>, <a href="qcloseevent.html">QCloseEvent</a>)</h3><h3 class="fn"><a name="critical" />int QMessageBox.critical (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, int&#160;<i>button0</i>, int&#160;<i>button1</i>, int&#160;<i>button2</i>&#160;=&#160;0)</h3><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>
<ul>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.NoButton</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Ok</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Cancel</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Yes</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.No</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Abort</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Retry</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Ignore</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.YesAll</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.NoAll</a></li>
</ul>
<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>
<p>One button can be OR-ed with <a href="qmessagebox.html#Button-enum">QMessageBox.Default</a>, and one button can be OR-ed with <a href="qmessagebox.html#Button-enum">QMessageBox.Escape</a>.</p>
<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>
<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>
<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>
<h3 class="fn"><a name="critical-2" />int QMessageBox.critical (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, <a href="qstring.html">QString</a>&#160;<i>button0Text</i>&#160;=&#160;QString(), <a href="qstring.html">QString</a>&#160;<i>button1Text</i>&#160;=&#160;QString(), <a href="qstring.html">QString</a>&#160;<i>button2Text</i>&#160;=&#160;QString(), int&#160;<i>defaultButtonNumber</i>&#160;=&#160;0, int&#160;<i>escapeButtonNumber</i>&#160;=&#160;-1)</h3><p>This is an overloaded member function, provided for convenience.</p>
<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>
<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>
<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>
<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>
<h3 class="fn"><a name="icon" /><a href="qmessagebox.html#Icon-enum">Icon</a> QMessageBox.icon (<i>self</i>)</h3><h3 class="fn"><a name="iconPixmap" /><a href="qpixmap.html">QPixmap</a> QMessageBox.iconPixmap (<i>self</i>)</h3><h3 class="fn"><a name="information" />int QMessageBox.information (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, int&#160;<i>button0</i>, int&#160;<i>button1</i>&#160;=&#160;0, int&#160;<i>button2</i>&#160;=&#160;0)</h3><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>
<ul>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.NoButton</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Ok</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Cancel</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Yes</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.No</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Abort</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Retry</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Ignore</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.YesAll</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.NoAll</a></li>
</ul>
<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>
<p>One button can be OR-ed with <a href="qmessagebox.html#Button-enum">QMessageBox.Default</a>, and one button can be OR-ed with <a href="qmessagebox.html#Button-enum">QMessageBox.Escape</a>.</p>
<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>
<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>
<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>
<h3 class="fn"><a name="information-2" />int QMessageBox.information (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, <a href="qstring.html">QString</a>&#160;<i>button0Text</i>&#160;=&#160;QString(), <a href="qstring.html">QString</a>&#160;<i>button1Text</i>&#160;=&#160;QString(), <a href="qstring.html">QString</a>&#160;<i>button2Text</i>&#160;=&#160;QString(), int&#160;<i>defaultButtonNumber</i>&#160;=&#160;0, int&#160;<i>escapeButtonNumber</i>&#160;=&#160;-1)</h3><p>This is an overloaded member function, provided for convenience.</p>
<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>
<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>
<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>
<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>
<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>
<h3 class="fn"><a name="keyPressEvent" />QMessageBox.keyPressEvent (<i>self</i>, <a href="qkeyevent.html">QKeyEvent</a>)</h3><h3 class="fn"><a name="question" />int QMessageBox.question (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, int&#160;<i>button0</i>, int&#160;<i>button1</i>&#160;=&#160;0, int&#160;<i>button2</i>&#160;=&#160;0)</h3><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>
<ul>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.NoButton</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Ok</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Cancel</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Yes</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.No</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Abort</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Retry</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Ignore</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.YesAll</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.NoAll</a></li>
</ul>
<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>
<p>One button can be OR-ed with <a href="qmessagebox.html#Button-enum">QMessageBox.Default</a>, and one button can be OR-ed with <a href="qmessagebox.html#Button-enum">QMessageBox.Escape</a>.</p>
<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>
<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>
<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>
<h3 class="fn"><a name="question-2" />int QMessageBox.question (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, <a href="qstring.html">QString</a>&#160;<i>button0Text</i>&#160;=&#160;QString(), <a href="qstring.html">QString</a>&#160;<i>button1Text</i>&#160;=&#160;QString(), <a href="qstring.html">QString</a>&#160;<i>button2Text</i>&#160;=&#160;QString(), int&#160;<i>defaultButtonNumber</i>&#160;=&#160;0, int&#160;<i>escapeButtonNumber</i>&#160;=&#160;-1)</h3><p>This is an overloaded member function, provided for convenience.</p>
<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>
<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>
<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>
<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>
<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>
<h3 class="fn"><a name="resizeEvent" />QMessageBox.resizeEvent (<i>self</i>, <a href="qresizeevent.html">QResizeEvent</a>)</h3><h3 class="fn"><a name="setButtonText" />QMessageBox.setButtonText (<i>self</i>, int&#160;<i>button</i>, <a href="qstring.html">QString</a>)</h3><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>
<p>See also <a href="qmessagebox.html#buttonText">buttonText</a>().</p>
<h3 class="fn"><a name="setIcon" />QMessageBox.setIcon (<i>self</i>, <a href="qmessagebox.html#Icon-enum">Icon</a>)</h3><h3 class="fn"><a name="setIconPixmap" />QMessageBox.setIconPixmap (<i>self</i>, <a href="qpixmap.html">QPixmap</a>)</h3><h3 class="fn"><a name="setText" />QMessageBox.setText (<i>self</i>, <a href="qstring.html">QString</a>)</h3><h3 class="fn"><a name="setTextFormat" />QMessageBox.setTextFormat (<i>self</i>, <a href="qt.html#TextFormat-enum">Qt.TextFormat</a>)</h3><h3 class="fn"><a name="showEvent" />QMessageBox.showEvent (<i>self</i>, <a href="qshowevent.html">QShowEvent</a>)</h3><h3 class="fn"><a name="sizeHint" /><a href="qsize.html">QSize</a> QMessageBox.sizeHint (<i>self</i>)</h3><h3 class="fn"><a name="standardIcon" /><a href="qpixmap.html">QPixmap</a> QMessageBox.standardIcon (<a href="qmessagebox.html#Icon-enum">Icon</a>&#160;<i>icon</i>)</h3><h3 class="fn"><a name="text" /><a href="qstring.html">QString</a> QMessageBox.text (<i>self</i>)</h3><h3 class="fn"><a name="textFormat" /><a href="qt.html#TextFormat-enum">Qt.TextFormat</a> QMessageBox.textFormat (<i>self</i>)</h3><h3 class="fn"><a name="warning" />int QMessageBox.warning (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, int&#160;<i>button0</i>, int&#160;<i>button1</i>, int&#160;<i>button2</i>&#160;=&#160;0)</h3><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>
<ul>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.NoButton</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Ok</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Cancel</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Yes</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.No</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Abort</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Retry</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.Ignore</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.YesAll</a></li>
<li><a href="qmessagebox.html#Button-enum">QMessageBox.NoAll</a></li>
</ul>
<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>
<p>One button can be OR-ed with <a href="qmessagebox.html#Button-enum">QMessageBox.Default</a>, and one button can be OR-ed with <a href="qmessagebox.html#Button-enum">QMessageBox.Escape</a>.</p>
<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>
<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>
<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>
<h3 class="fn"><a name="warning-2" />int QMessageBox.warning (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>caption</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, <a href="qstring.html">QString</a>&#160;<i>button0Text</i>&#160;=&#160;QString(), <a href="qstring.html">QString</a>&#160;<i>button1Text</i>&#160;=&#160;QString(), <a href="qstring.html">QString</a>&#160;<i>button2Text</i>&#160;=&#160;QString(), int&#160;<i>defaultButtonNumber</i>&#160;=&#160;0, int&#160;<i>escapeButtonNumber</i>&#160;=&#160;-1)</h3><p>This is an overloaded member function, provided for convenience.</p>
<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>
<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>
<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>
<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>
<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>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>