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
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
|
'\" t
.TH QMessageBox 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QMessageBox \- Modal dialog with a short message, an icon, and some buttons
.SH SYNOPSIS
\fC#include <qmessagebox.h>\fR
.PP
Inherits QDialog.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "enum \fBIcon\fR { NoIcon = 0, Information = 1, Warning = 2, Critical = 3, Question = 4 }"
.br
.ti -1c
.BI "\fBQMessageBox\fR ( QWidget * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "\fBQMessageBox\fR ( const QString & caption, const QString & text, Icon icon, int button0, int button1, int button2, QWidget * parent = 0, const char * name = 0, bool modal = TRUE, WFlags f = WStyle_DialogBorder )"
.br
.ti -1c
.BI "\fB~QMessageBox\fR ()"
.br
.ti -1c
.BI "QString \fBtext\fR () const"
.br
.ti -1c
.BI "void \fBsetText\fR ( const QString & )"
.br
.ti -1c
.BI "Icon \fBicon\fR () const"
.br
.ti -1c
.BI "void \fBsetIcon\fR ( Icon )"
.br
.ti -1c
.BI "const QPixmap * \fBiconPixmap\fR () const"
.br
.ti -1c
.BI "void \fBsetIconPixmap\fR ( const QPixmap & )"
.br
.ti -1c
.BI "QString \fBbuttonText\fR ( int button ) const"
.br
.ti -1c
.BI "void \fBsetButtonText\fR ( int button, const QString & text )"
.br
.ti -1c
.BI "virtual void \fBadjustSize\fR ()"
.br
.ti -1c
.BI "TextFormat \fBtextFormat\fR () const"
.br
.ti -1c
.BI "void \fBsetTextFormat\fR ( TextFormat )"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "int \fBinformation\fR ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1 = 0, int button2 = 0 )"
.br
.ti -1c
.BI "int \fBinformation\fR ( QWidget * parent, const QString & caption, const QString & text, const QString & button0Text = QString::null, const QString & button1Text = QString::null, const QString & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )"
.br
.ti -1c
.BI "int \fBquestion\fR ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1 = 0, int button2 = 0 )"
.br
.ti -1c
.BI "int \fBquestion\fR ( QWidget * parent, const QString & caption, const QString & text, const QString & button0Text = QString::null, const QString & button1Text = QString::null, const QString & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )"
.br
.ti -1c
.BI "int \fBwarning\fR ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1, int button2 = 0 )"
.br
.ti -1c
.BI "int \fBwarning\fR ( QWidget * parent, const QString & caption, const QString & text, const QString & button0Text = QString::null, const QString & button1Text = QString::null, const QString & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )"
.br
.ti -1c
.BI "int \fBcritical\fR ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1, int button2 = 0 )"
.br
.ti -1c
.BI "int \fBcritical\fR ( QWidget * parent, const QString & caption, const QString & text, const QString & button0Text = QString::null, const QString & button1Text = QString::null, const QString & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )"
.br
.ti -1c
.BI "void \fBabout\fR ( QWidget * parent, const QString & caption, const QString & text )"
.br
.ti -1c
.BI "void \fBaboutQt\fR ( QWidget * parent, const QString & caption = QString::null )"
.br
.ti -1c
.BI "int message ( const QString & caption, const QString & text, const QString & buttonText = QString::null, QWidget * parent = 0, const char * = 0 ) \fI(obsolete)\fR"
.br
.ti -1c
.BI "bool query ( const QString & caption, const QString & text, const QString & yesButtonText = QString::null, const QString & noButtonText = QString::null, QWidget * parent = 0, const char * = 0 ) \fI(obsolete)\fR"
.br
.ti -1c
.BI "QPixmap standardIcon ( Icon icon, GUIStyle style ) \fI(obsolete)\fR"
.br
.ti -1c
.BI "QPixmap \fBstandardIcon\fR ( Icon icon )"
.br
.in -1c
.SS "Properties"
.in +1c
.ti -1c
.BI "Icon \fBicon\fR - the message box's icon"
.br
.ti -1c
.BI "QPixmap \fBiconPixmap\fR - the current icon"
.br
.ti -1c
.BI "QString \fBtext\fR - the message box text to be displayed"
.br
.ti -1c
.BI "TextFormat \fBtextFormat\fR - the format of the text displayed by the message box"
.br
.in -1c
.SH DESCRIPTION
The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons.
.PP
Message boxes are used to provide informative messages and to ask simple questions.
.PP
QMessageBox provides a range of different messages, arranged roughly along two axes: severity and complexity.
.PP
Severity is <center>.nf
.TS
l - l. Question For message boxes that ask a question as part of normal operation. Some style guides recommend using Information for this purpose. Information For message boxes that are part of normal operation. Warning For message boxes that tell the user about unusual errors. Critical
.TE
.fi
</center>
.PP
The message box has a different icon for each of the severity levels.
.PP
Complexity is one button (OK) for simple messages, or two or even three buttons for questions.
.PP
There are static functions for the most common cases.
.PP
Examples:
.)l
.PP
If a program is unable to find a supporting file, but can do perfectly well without it:
.PP
.nf
.br
QMessageBox::information( this, "Application name",
.br
"Unable to find the user preferences file.\\n"
.br
"The factory default will be used instead." );
.br
.fi
.PP
question() is useful for simple yes/no questions:
.PP
.nf
.br
if ( QFile::exists( filename ) &&
.br
QMessageBox::question(
.br
this,
.br
tr("Overwrite File? -- Application Name"),
.br
tr("A file called %1 already exists."
.br
"Do you want to overwrite it?")
.br
.arg( filename ),
.br
tr("&Yes"), tr("&No"),
.br
QString::null, 0, 1 ) )
.br
return false;
.br
.fi
.PP
warning() can be used to tell the user about unusual errors, or errors which can't be easily fixed:
.PP
.nf
.br
switch( QMessageBox::warning( this, "Application name",
.br
"Could not connect to the <mumble> server.\\n"
.br
"This program can't function correctly "
.br
"without the server.\\n\\n",
.br
"Retry",
.br
"Quit", 0, 0, 1 ) ) {
.br
case 0: // The user clicked the Retry again button or pressed Enter
.br
// try again
.br
break;
.br
case 1: // The user clicked the Quit or pressed Escape
.br
// exit
.br
break;
.br
}
.br
.fi
.PP
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 setTextFormat().
.PP
Note that the Microsoft Windows User Interface Guidelines recommend using the application name as the window's caption.
.PP
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.
.PP
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:
.PP
.nf
.br
switch( QMessageBox::information( this, "Application name here",
.br
"The document contains unsaved changes\\n"
.br
"Do you want to save the changes before exiting?",
.br
"&Save", "&Discard", "Cancel",
.br
0, // Enter == button 0
.br
2 ) ) { // Escape == button 2
.br
case 0: // Save clicked or Alt+S pressed or Enter pressed.
.br
// save
.br
break;
.br
case 1: // Discard clicked or Alt+D pressed
.br
// don't save but exit
.br
break;
.br
case 2: // Cancel clicked or Escape pressed
.br
// don't exit
.br
break;
.br
}
.br
.fi
.PP
The Escape button cancels the entire exit operation, and pressing Enter causes the changes to be saved before the exit occurs.
.PP
Disk full errors are unusual and they certainly can be hard to correct. This example uses predefined buttons instead of hard-coded button texts:
.PP
.nf
.br
switch( QMessageBox::warning( this, "Application name here",
.br
"Could not save the user preferences,\\n"
.br
"because the disk is full. You can delete\\n"
.br
"some files and press Retry, or you can\\n"
.br
"abort the Save Preferences operation.",
.br
QMessageBox::Retry | QMessageBox::Default,
.br
QMessageBox::Abort | QMessageBox::Escape )) {
.br
case QMessageBox::Retry: // Retry clicked or Enter pressed
.br
// try again
.br
break;
.br
case QMessageBox::Abort: // Abort clicked or Escape pressed
.br
// abort
.br
break;
.br
}
.br
.fi
.PP
The critical() function should be reserved for critical errors. In this example errorDetails is a QString or const char*, and QString is used to concatenate several strings:
.PP
.nf
.br
QMessageBox::critical( 0, "Application name here",
.br
QString("An internal error occurred. Please ") +
.br
"call technical support at 1234-56789 and report\\n"+
.br
"these numbers:\\n\\n" + errorDetails +
.br
"\\n\\nApplication will now exit." );
.br
.fi
.PP
In this example an OK button is displayed.
.PP
QMessageBox provides a very simple About box which displays an appropriate icon and the string you provide:
.PP
.nf
.br
QMessageBox::about( this, "About <Application>",
.br
"<Application> is a <one-paragraph blurb>\\n\\n"
.br
"Copyright 1991-2003 Such-and-such. "
.br
"<License words here.>\\n\\n"
.br
"For technical support, call 1234-56789 or see\\n"
.br
"http://www.such-and-such.com/Application/\\n" );
.br
.fi
.PP
See about() for more information.
.PP
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 aboutQt().
.PP
If none of the standard message boxes is suitable, you can create a QMessageBox from scratch and use custom button texts:
.PP
.nf
.br
QMessageBox mb( "Application name here",
.br
"Saving the file will overwrite the original file on the disk.\\n"
.br
"Do you really want to save?",
.br
QMessageBox::Information,
.br
QMessageBox::Yes | QMessageBox::Default,
.br
QMessageBox::No,
.br
QMessageBox::Cancel | QMessageBox::Escape );
.br
mb.setButtonText( QMessageBox::Yes, "Save" );
.br
mb.setButtonText( QMessageBox::No, "Discard" );
.br
switch( mb.exec() ) {
.br
case QMessageBox::Yes:
.br
// save and exit
.br
break;
.br
case QMessageBox::No:
.br
// exit without saving
.br
break;
.br
case QMessageBox::Cancel:
.br
// don't save and don't exit
.br
break;
.br
}
.br
.fi
.PP
QMessageBox defines two enum types: Icon and an unnamed button type. Icon defines the Question, Information, Warning, and Critical icons for each GUI style. It is used by the constructor and by the static member functions question(), information(), warning() and critical(). A function called standardIcon() gives you access to the various icons.
.PP
The button types are:
.TP
Ok - the default for single-button message boxes
.TP
Cancel - note that this is \fInot\fR automatically Escape
.TP
Yes
.TP
No
.TP
Abort
.TP
Retry
.TP
Ignore
.TP
YesAll
.TP
NoAll
.PP
Button types can be combined with two modifiers by using OR, '|':
.TP
Default - makes pressing Enter equivalent to clicking this button. Normally used with Ok, Yes or similar.
.TP
Escape - makes pressing Escape equivalent to clicking this button. Normally used with Abort, Cancel or similar.
.PP
The text(), icon() and iconPixmap() functions provide access to the current text and pixmap of the message box. The setText(), setIcon() and setIconPixmap() let you change it. The difference between setIcon() and setIconPixmap() is that the former accepts a QMessageBox::Icon and can be used to set standard icons, whereas the latter accepts a QPixmap and can be used to set custom icons.
.PP
setButtonText() and buttonText() provide access to the buttons.
.PP
QMessageBox has no signals or slots.
.PP
.ce 1
.B "[Image Omitted]"
.PP
.ce 1
.B "[Image Omitted]"
.PP
See also QDialog, Isys on error messages, GUI Design Handbook: Message Box, and Dialog Classes.
.SS "Member Type Documentation"
.SH "QMessageBox::Icon"
This enum has the following values:
.TP
\fCQMessageBox::NoIcon\fR - the message box does not have any icon.
.TP
\fCQMessageBox::Question\fR - an icon indicating that the message is asking a question.
.TP
\fCQMessageBox::Information\fR - an icon indicating that the message is nothing out of the ordinary.
.TP
\fCQMessageBox::Warning\fR - an icon indicating that the message is a warning, but can be dealt with.
.TP
\fCQMessageBox::Critical\fR - an icon indicating that the message represents a critical problem.
.PP
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QMessageBox::QMessageBox ( QWidget * parent = 0, const char * name = 0 )"
Constructs a message box with no text and a button with the label" OK".
.PP
If \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR.
.PP
The \fIparent\fR and \fIname\fR arguments are passed to the QDialog constructor.
.SH "QMessageBox::QMessageBox ( const QString & caption, const QString & text, Icon icon, int button0, int button1, int button2, QWidget * parent = 0, const char * name = 0, bool modal = TRUE, WFlags f = WStyle_DialogBorder )"
Constructs a message box with a \fIcaption\fR, a \fItext\fR, an \fIicon\fR, and up to three buttons.
.PP
The \fIicon\fR must be one of the following:
.TP
QMessageBox::NoIcon
.TP
QMessageBox::Question
.TP
QMessageBox::Information
.TP
QMessageBox::Warning
.TP
QMessageBox::Critical
.PP
Each button, \fIbutton0\fR, \fIbutton1\fR and \fIbutton2\fR, can have one of the following values:
.TP
QMessageBox::NoButton
.TP
QMessageBox::Ok
.TP
QMessageBox::Cancel
.TP
QMessageBox::Yes
.TP
QMessageBox::No
.TP
QMessageBox::Abort
.TP
QMessageBox::Retry
.TP
QMessageBox::Ignore
.TP
QMessageBox::YesAll
.TP
QMessageBox::NoAll
.PP
Use QMessageBox::NoButton for the later parameters to have fewer than three buttons in your message box. If you don't specify any buttons at all, QMessageBox will provide an Ok button.
.PP
One of the buttons can be OR-ed with the \fCQMessageBox::Default\fR flag to make it the default button (clicked when Enter is pressed).
.PP
One of the buttons can be OR-ed with the \fCQMessageBox::Escape\fR flag to make it the cancel or close button (clicked when Escape is pressed).
.PP
Example:
.PP
.nf
.br
QMessageBox mb( "Application Name",
.br
"Hardware failure.\\n\\nDisk error detected\\nDo you want to stop?",
.br
QMessageBox::Question,
.br
QMessageBox::Yes | QMessageBox::Default,
.br
QMessageBox::No | QMessageBox::Escape,
.br
QMessageBox::NoButton );
.br
if ( mb.exec() == QMessageBox::No )
.br
// try again
.br
.fi
.PP
If \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR.
.PP
If \fImodal\fR is TRUE the message box is modal; otherwise it is modeless.
.PP
The \fIparent\fR, \fIname\fR, \fImodal\fR, and \fIf\fR arguments are passed to the QDialog constructor.
.PP
See also caption, text, and icon.
.SH "QMessageBox::~QMessageBox ()"
Destroys the message box.
.SH "void QMessageBox::about ( QWidget * parent, const QString & caption, const QString & text )\fC [static]\fR"
Displays a simple about box with caption \fIcaption\fR and text \fItext\fR. The about box's parent is \fIparent\fR.
.PP
about() looks for a suitable icon in four locations: <ol type=1>
.TP
It prefers parent->icon() if that exists.
.TP
If not, it tries the top-level widget containing \fIparent\fR.
.TP
If that fails, it tries the main widget.
.TP
As a last resort it uses the Information icon.
.PP
The about box has a single button labelled "OK".
.PP
See also QWidget::icon and QApplication::mainWidget().
.PP
Examples:
.)l action/application.cpp, application/application.cpp, chart/chartform.cpp, helpviewer/helpwindow.cpp, mdi/application.cpp, menu/menu.cpp, and themes/themes.cpp.
.SH "void QMessageBox::aboutQt ( QWidget * parent, const QString & caption = QString::null )\fC [static]\fR"
Displays a simple message box about Qt, with caption \fIcaption\fR and centered over \fIparent\fR (if \fIparent\fR is not 0). The message includes the version number of Qt being used by the application.
.PP
This is useful for inclusion in the Help menu of an application. See the examples/menu/menu.cpp example.
.PP
QApplication provides this functionality as a slot.
.PP
See also QApplication::aboutQt().
.PP
Examples:
.)l action/application.cpp, application/application.cpp, chart/chartform.cpp, helpviewer/helpwindow.cpp, menu/menu.cpp, themes/themes.cpp, and trivial/trivial.cpp.
.SH "void QMessageBox::adjustSize ()\fC [virtual]\fR"
Adjusts the size of the message box to fit the contents just before QDialog::exec() or QDialog::show() is called.
.PP
This function will not be called if the message box has been explicitly resized before showing it.
.PP
Reimplemented from QWidget.
.SH "QString QMessageBox::buttonText ( int button ) const"
Returns the text of the message box button \fIbutton\fR, or QString::null if the message box does not contain the button.
.PP
See also setButtonText().
.SH "int QMessageBox::critical ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1, int button2 = 0 )\fC [static]\fR"
Opens a critical message box with the caption \fIcaption\fR and the text \fItext\fR. The dialog may have up to three buttons. Each of the button parameters, \fIbutton0\fR, \fIbutton1\fR and \fIbutton2\fR may be set to one of the following values:
.TP
QMessageBox::NoButton
.TP
QMessageBox::Ok
.TP
QMessageBox::Cancel
.TP
QMessageBox::Yes
.TP
QMessageBox::No
.TP
QMessageBox::Abort
.TP
QMessageBox::Retry
.TP
QMessageBox::Ignore
.TP
QMessageBox::YesAll
.TP
QMessageBox::NoAll
.PP
If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.
.PP
One button can be OR-ed with \fCQMessageBox::Default\fR, and one button can be OR-ed with \fCQMessageBox::Escape\fR.
.PP
Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked.
.PP
If \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR.
.PP
See also information(), question(), and warning().
.PP
Examples:
.)l network/archivesearch/archivedialog.ui.h, network/ftpclient/ftpmainwindow.ui.h, process/process.cpp, and xml/outliner/outlinetree.cpp.
.SH "int QMessageBox::critical ( QWidget * parent, const QString & caption, const QString & text, const QString & button0Text = QString::null, const QString & button1Text = QString::null, const QString & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
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).
.PP
\fIbutton0Text\fR is the text of the first button, and is optional. If \fIbutton0Text\fR is not supplied, "OK" (translated) will be used. \fIbutton1Text\fR is the text of the second button, and is optional, and \fIbutton2Text\fR is the text of the third button, and is optional. \fIdefaultButtonNumber\fR (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). \fIescapeButtonNumber\fR 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.
.PP
If \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR.
.PP
See also information(), question(), and warning().
.SH "Icon QMessageBox::icon () const"
Returns the message box's icon. See the "icon" property for details.
.SH "const QPixmap * QMessageBox::iconPixmap () const"
Returns the current icon. See the "iconPixmap" property for details.
.SH "int QMessageBox::information ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1 = 0, int button2 = 0 )\fC [static]\fR"
Opens an information message box with the caption \fIcaption\fR and the text \fItext\fR. The dialog may have up to three buttons. Each of the buttons, \fIbutton0\fR, \fIbutton1\fR and \fIbutton2\fR may be set to one of the following values:
.TP
QMessageBox::NoButton
.TP
QMessageBox::Ok
.TP
QMessageBox::Cancel
.TP
QMessageBox::Yes
.TP
QMessageBox::No
.TP
QMessageBox::Abort
.TP
QMessageBox::Retry
.TP
QMessageBox::Ignore
.TP
QMessageBox::YesAll
.TP
QMessageBox::NoAll
.PP
If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.
.PP
One button can be OR-ed with \fCQMessageBox::Default\fR, and one button can be OR-ed with \fCQMessageBox::Escape\fR.
.PP
Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked.
.PP
If \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR.
.PP
See also question(), warning(), and critical().
.PP
Examples:
.)l action/application.cpp, application/application.cpp, dirview/dirview.cpp, fileiconview/qfileiconview.cpp, picture/picture.cpp, qwerty/qwerty.cpp, and simple/main.cpp.
.SH "int QMessageBox::information ( QWidget * parent, const QString & caption, const QString & text, const QString & button0Text = QString::null, const QString & button1Text = QString::null, const QString & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Displays an information message box with caption \fIcaption\fR, text \fItext\fR and one, two or three buttons. Returns the index of the button that was clicked (0, 1 or 2).
.PP
\fIbutton0Text\fR is the text of the first button, and is optional. If \fIbutton0Text\fR is not supplied, "OK" (translated) will be used. \fIbutton1Text\fR is the text of the second button, and is optional. \fIbutton2Text\fR is the text of the third button, and is optional. \fIdefaultButtonNumber\fR (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). \fIescapeButtonNumber\fR 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.
.PP
If \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR.
.PP
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.
.PP
See also question(), warning(), and critical().
.SH "int QMessageBox::message ( const QString & caption, const QString & text, const QString & buttonText = QString::null, QWidget * parent = 0, const char * = 0 )\fC [static]\fR"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Opens a modal message box directly using the specified parameters.
.PP
Please use information(), warning(), question(), or critical() instead.
.PP
Example: grapher/grapher.cpp.
.SH "bool QMessageBox::query ( const QString & caption, const QString & text, const QString & yesButtonText = QString::null, const QString & noButtonText = QString::null, QWidget * parent = 0, const char * = 0 )\fC [static]\fR"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Queries the user using a modal message box with two buttons. Note that \fIcaption\fR is not always shown, it depends on the window manager.
.PP
Please use information(), question(), warning(), or critical() instead.
.SH "int QMessageBox::question ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1 = 0, int button2 = 0 )\fC [static]\fR"
Opens a question message box with the caption \fIcaption\fR and the text \fItext\fR. The dialog may have up to three buttons. Each of the buttons, \fIbutton0\fR, \fIbutton1\fR and \fIbutton2\fR may be set to one of the following values:
.TP
QMessageBox::NoButton
.TP
QMessageBox::Ok
.TP
QMessageBox::Cancel
.TP
QMessageBox::Yes
.TP
QMessageBox::No
.TP
QMessageBox::Abort
.TP
QMessageBox::Retry
.TP
QMessageBox::Ignore
.TP
QMessageBox::YesAll
.TP
QMessageBox::NoAll
.PP
If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.
.PP
One button can be OR-ed with \fCQMessageBox::Default\fR, and one button can be OR-ed with \fCQMessageBox::Escape\fR.
.PP
Returns the identity (QMessageBox::Yes, or QMessageBox::No, etc.) of the button that was clicked.
.PP
If \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR.
.PP
See also information(), warning(), and critical().
.SH "int QMessageBox::question ( QWidget * parent, const QString & caption, const QString & text, const QString & button0Text = QString::null, const QString & button1Text = QString::null, const QString & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Displays a question message box with caption \fIcaption\fR, text \fItext\fR and one, two or three buttons. Returns the index of the button that was clicked (0, 1 or 2).
.PP
\fIbutton0Text\fR is the text of the first button, and is optional. If \fIbutton0Text\fR is not supplied, "OK" (translated) will be used. \fIbutton1Text\fR is the text of the second button, and is optional. \fIbutton2Text\fR is the text of the third button, and is optional. \fIdefaultButtonNumber\fR (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). \fIescapeButtonNumber\fR 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.
.PP
If \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR.
.PP
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.
.PP
See also information(), warning(), and critical().
.SH "void QMessageBox::setButtonText ( int button, const QString & text )"
Sets the text of the message box button \fIbutton\fR to \fItext\fR. Setting the text of a button that is not in the message box is silently ignored.
.PP
See also buttonText().
.SH "void QMessageBox::setIcon ( Icon )"
Sets the message box's icon. See the "icon" property for details.
.SH "void QMessageBox::setIconPixmap ( const QPixmap & )"
Sets the current icon. See the "iconPixmap" property for details.
.SH "void QMessageBox::setText ( const QString & )"
Sets the message box text to be displayed. See the "text" property for details.
.SH "void QMessageBox::setTextFormat ( TextFormat )"
Sets the format of the text displayed by the message box. See the "textFormat" property for details.
.SH "QPixmap QMessageBox::standardIcon ( Icon icon )\fC [static]\fR"
Returns the pixmap used for a standard icon. This allows the pixmaps to be used in more complex message boxes. \fIicon\fR specifies the required icon, e.g. QMessageBox::Question, QMessageBox::Information, QMessageBox::Warning or QMessageBox::Critical.
.SH "QPixmap QMessageBox::standardIcon ( Icon icon, GUIStyle style )\fC [static]\fR"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Returns the pixmap used for a standard icon. This allows the pixmaps to be used in more complex message boxes. \fIicon\fR specifies the required icon, e.g. QMessageBox::Information, QMessageBox::Warning or QMessageBox::Critical.
.PP
\fIstyle\fR is unused.
.SH "QString QMessageBox::text () const"
Returns the message box text to be displayed. See the "text" property for details.
.SH "TextFormat QMessageBox::textFormat () const"
Returns the format of the text displayed by the message box. See the "textFormat" property for details.
.SH "int QMessageBox::warning ( QWidget * parent, const QString & caption, const QString & text, int button0, int button1, int button2 = 0 )\fC [static]\fR"
Opens a warning message box with the caption \fIcaption\fR and the text \fItext\fR. The dialog may have up to three buttons. Each of the button parameters, \fIbutton0\fR, \fIbutton1\fR and \fIbutton2\fR may be set to one of the following values:
.TP
QMessageBox::NoButton
.TP
QMessageBox::Ok
.TP
QMessageBox::Cancel
.TP
QMessageBox::Yes
.TP
QMessageBox::No
.TP
QMessageBox::Abort
.TP
QMessageBox::Retry
.TP
QMessageBox::Ignore
.TP
QMessageBox::YesAll
.TP
QMessageBox::NoAll
.PP
If you don't want all three buttons, set the last button, or last two buttons to QMessageBox::NoButton.
.PP
One button can be OR-ed with \fCQMessageBox::Default\fR, and one button can be OR-ed with \fCQMessageBox::Escape\fR.
.PP
Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.) of the button that was clicked.
.PP
If \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR.
.PP
See also information(), question(), and critical().
.PP
Examples:
.)l chart/chartform.cpp, i18n/main.cpp, network/mail/smtp.cpp, qwerty/qwerty.cpp, showimg/showimg.cpp, and sound/sound.cpp.
.SH "int QMessageBox::warning ( QWidget * parent, const QString & caption, const QString & text, const QString & button0Text = QString::null, const QString & button1Text = QString::null, const QString & button2Text = QString::null, int defaultButtonNumber = 0, int escapeButtonNumber = -1 )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
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).
.PP
\fIbutton0Text\fR is the text of the first button, and is optional. If \fIbutton0Text\fR is not supplied, "OK" (translated) will be used. \fIbutton1Text\fR is the text of the second button, and is optional, and \fIbutton2Text\fR is the text of the third button, and is optional. \fIdefaultButtonNumber\fR (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). \fIescapeButtonNumber\fR 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.
.PP
If \fIparent\fR is 0, the message box becomes an application-global modal dialog box. If \fIparent\fR is a widget, the message box becomes modal relative to \fIparent\fR.
.PP
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.
.PP
See also information(), question(), and critical().
.SS "Property Documentation"
.SH "Icon icon"
This property holds the message box's icon.
.PP
The icon of the message box can be one of the following predefined icons:
.TP
QMessageBox::NoIcon
.TP
QMessageBox::Question
.TP
QMessageBox::Information
.TP
QMessageBox::Warning
.TP
QMessageBox::Critical
.PP
The actual pixmap used for displaying the icon depends on the current GUI style. You can also set a custom pixmap icon using the QMessageBox::iconPixmap property. The default icon is QMessageBox::NoIcon.
.PP
See also iconPixmap.
.PP
Set this property's value with setIcon() and get this property's value with icon().
.SH "QPixmap iconPixmap"
This property holds the current icon.
.PP
The icon currently used by the message box. Note that it's often hard to draw one pixmap that looks appropriate in both Motif and Windows GUI styles; you may want to draw two pixmaps.
.PP
See also icon.
.PP
Set this property's value with setIconPixmap() and get this property's value with iconPixmap().
.SH "QString text"
This property holds the message box text to be displayed.
.PP
The text will be interpreted either as a plain text or as rich text, depending on the text format setting (QMessageBox::textFormat). The default setting is AutoText, i.e. the message box will try to auto-detect the format of the text.
.PP
The default value of this property is QString::null.
.PP
See also textFormat.
.PP
Set this property's value with setText() and get this property's value with text().
.SH "TextFormat textFormat"
This property holds the format of the text displayed by the message box.
.PP
The current text format used by the message box. See the Qt::TextFormat enum for an explanation of the possible options.
.PP
The default format is AutoText.
.PP
See also text.
.PP
Set this property's value with setTextFormat() and get this property's value with textFormat().
.SH "SEE ALSO"
.BR http://doc.trolltech.com/qmessagebox.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qmessagebox.3qt) and the Qt
version (3.3.8).
|