source: trunk/doc/html/qmessagebox.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 48.8 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/dialogs/qmessagebox.cpp:149 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QMessageBox Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QMessageBox Class Reference</h1>
33
34<p>The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qmessagebox-h.html">qmessagebox.h</a>&gt;</tt>
37<p>Inherits <a href="qdialog.html">QDialog</a>.
38<p><a href="qmessagebox-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn>enum <a href="#Icon-enum"><b>Icon</b></a> { NoIcon = 0, Information = 1, Warning = 2, Critical = 3, Question = 4 }</li>
42<li class=fn><a href="#QMessageBox"><b>QMessageBox</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
43<li class=fn><a href="#QMessageBox-2"><b>QMessageBox</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, Icon&nbsp;icon, int&nbsp;button0, int&nbsp;button1, int&nbsp;button2, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;modal = TRUE, WFlags&nbsp;f = WStyle_DialogBorder )</li>
44<li class=fn><a href="#~QMessageBox"><b>~QMessageBox</b></a> ()</li>
45<li class=fn>QString <a href="#text"><b>text</b></a> () const</li>
46<li class=fn>void <a href="#setText"><b>setText</b></a> ( const QString &amp; )</li>
47<li class=fn>Icon <a href="#icon"><b>icon</b></a> () const</li>
48<li class=fn>void <a href="#setIcon"><b>setIcon</b></a> ( Icon )</li>
49<li class=fn>const QPixmap * <a href="#iconPixmap"><b>iconPixmap</b></a> () const</li>
50<li class=fn>void <a href="#setIconPixmap"><b>setIconPixmap</b></a> ( const QPixmap &amp; )</li>
51<li class=fn>QString <a href="#buttonText"><b>buttonText</b></a> ( int&nbsp;button ) const</li>
52<li class=fn>void <a href="#setButtonText"><b>setButtonText</b></a> ( int&nbsp;button, const&nbsp;QString&nbsp;&amp;&nbsp;text )</li>
53<li class=fn>virtual void <a href="#adjustSize"><b>adjustSize</b></a> ()</li>
54<li class=fn>TextFormat <a href="#textFormat"><b>textFormat</b></a> () const</li>
55<li class=fn>void <a href="#setTextFormat"><b>setTextFormat</b></a> ( TextFormat )</li>
56</ul>
57<h2>Static Public Members</h2>
58<ul>
59<li class=fn>int <a href="#information"><b>information</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, int&nbsp;button0, int&nbsp;button1 = 0, int&nbsp;button2 = 0 )</li>
60<li class=fn>int <a href="#information-2"><b>information</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QString&nbsp;&amp;&nbsp;button0Text = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;button1Text = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;button2Text = QString::null, int&nbsp;defaultButtonNumber = 0, int&nbsp;escapeButtonNumber = -1 )</li>
61<li class=fn>int <a href="#question"><b>question</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, int&nbsp;button0, int&nbsp;button1 = 0, int&nbsp;button2 = 0 )</li>
62<li class=fn>int <a href="#question-2"><b>question</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QString&nbsp;&amp;&nbsp;button0Text = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;button1Text = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;button2Text = QString::null, int&nbsp;defaultButtonNumber = 0, int&nbsp;escapeButtonNumber = -1 )</li>
63<li class=fn>int <a href="#warning"><b>warning</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, int&nbsp;button0, int&nbsp;button1, int&nbsp;button2 = 0 )</li>
64<li class=fn>int <a href="#warning-2"><b>warning</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QString&nbsp;&amp;&nbsp;button0Text = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;button1Text = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;button2Text = QString::null, int&nbsp;defaultButtonNumber = 0, int&nbsp;escapeButtonNumber = -1 )</li>
65<li class=fn>int <a href="#critical"><b>critical</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, int&nbsp;button0, int&nbsp;button1, int&nbsp;button2 = 0 )</li>
66<li class=fn>int <a href="#critical-2"><b>critical</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QString&nbsp;&amp;&nbsp;button0Text = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;button1Text = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;button2Text = QString::null, int&nbsp;defaultButtonNumber = 0, int&nbsp;escapeButtonNumber = -1 )</li>
67<li class=fn>void <a href="#about"><b>about</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text )</li>
68<li class=fn>void <a href="#aboutQt"><b>aboutQt</b></a> ( QWidget&nbsp;*&nbsp;parent, const&nbsp;QString&nbsp;&amp;&nbsp;caption = QString::null )</li>
69<li class=fn>int message ( const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QString&nbsp;&amp;&nbsp;buttonText = QString::null, QWidget&nbsp;*&nbsp;parent = 0, const char * = 0 ) &nbsp;<em>(obsolete)</em></li>
70<li class=fn>bool query ( const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QString&nbsp;&amp;&nbsp;yesButtonText = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;noButtonText = QString::null, QWidget&nbsp;*&nbsp;parent = 0, const char * = 0 ) &nbsp;<em>(obsolete)</em></li>
71<li class=fn>QPixmap standardIcon ( Icon&nbsp;icon, GUIStyle&nbsp;style ) &nbsp;<em>(obsolete)</em></li>
72<li class=fn>QPixmap <a href="#standardIcon"><b>standardIcon</b></a> ( Icon&nbsp;icon )</li>
73</ul>
74<h2>Properties</h2>
75<ul>
76<li class=fn>Icon <a href="#icon-prop"><b>icon</b></a>&nbsp;- the message box's icon</li>
77<li class=fn>QPixmap <a href="#iconPixmap-prop"><b>iconPixmap</b></a>&nbsp;- the current icon</li>
78<li class=fn>QString <a href="#text-prop"><b>text</b></a>&nbsp;- the message box text to be displayed</li>
79<li class=fn>TextFormat <a href="#textFormat-prop"><b>textFormat</b></a>&nbsp;- the format of the text displayed by the message box</li>
80</ul>
81<hr><a name="details"></a><h2>Detailed Description</h2>
82
83
84The QMessageBox class provides a modal dialog with a short message, an icon, and some buttons.
85
86
87<p> Message boxes are used to provide informative messages and to ask
88simple questions.
89<p> QMessageBox provides a range of different messages, arranged
90roughly along two axes: severity and complexity.
91<p> Severity is
92<center><table cellpadding="4" cellspacing="2" border="0">
93<tr bgcolor="#f0f0f0">
94<td valign="top"><center><img src="qmessagebox-quest.png"></center> <td valign="top">Question
95<td valign="top">For message boxes that ask a question as part of normal
96operation. Some style guides recommend using Information for this
97purpose.
98<tr bgcolor="#d0d0d0">
99<td valign="top"><center><img src="qmessagebox-info.png"></center> <td valign="top">Information
100<td valign="top">For message boxes that are part of normal operation.
101<tr bgcolor="#f0f0f0">
102<td valign="top"><center><img src="qmessagebox-warn.png"></center> <td valign="top">Warning
103<td valign="top">For message boxes that tell the user about unusual errors.
104<tr bgcolor="#d0d0d0">
105<td valign="top"><center><img src="qmessagebox-crit.png"></center> <td valign="top">Critical
106<td valign="top">For message boxes that tell the user about critical errors.
107</table></center>
108<p> The message box has a different icon for each of the severity levels.
109<p> Complexity is one button (OK) for simple messages, or two or even
110three buttons for questions.
111<p> There are static functions for the most common cases.
112<p> Examples:
113<p> If a program is unable to find a supporting file, but can do perfectly
114well without it:
115<p> <pre>
116 QMessageBox::<a href="#information">information</a>( this, "Application name",
117 "Unable to find the user preferences file.\n"
118 "The factory default will be used instead." );
119 </pre>
120
121<p> <a href="#question">question</a>() is useful for simple yes/no questions:
122<p> <pre>
123 if ( QFile::<a href="qfile.html#exists">exists</a>( filename ) &amp;&amp;
124 QMessageBox::<a href="#question">question</a>(
125 this,
126 <a href="qobject.html#tr">tr</a>("Overwrite File? -- Application Name"),
127 <a href="qobject.html#tr">tr</a>("A file called %1 already exists."
128 "Do you want to overwrite it?")
129 .arg( filename ),
130 <a href="qobject.html#tr">tr</a>("&amp;Yes"), tr("&amp;No"),
131 <a href="qstring.html#QString-null">QString::null</a>, 0, 1 ) )
132 return false;
133 </pre>
134
135<p> <a href="#warning">warning</a>() can be used to tell the user about unusual errors, or
136errors which can't be easily fixed:
137<p> <pre>
138 switch( QMessageBox::<a href="#warning">warning</a>( this, "Application name",
139 "Could not connect to the &lt;mumble&gt; server.\n"
140 "This program can't function correctly "
141 "without the server.\n\n",
142 "Retry",
143 "Quit", 0, 0, 1 ) ) {
144 case 0: // The user clicked the Retry again button or pressed Enter
145 // try again
146 break;
147 case 1: // The user clicked the Quit or pressed Escape
148 // exit
149 break;
150 }
151 </pre>
152
153<p> The text part of all message box messages can be either rich text
154or plain text. If you specify a rich text formatted string, it
155will be rendered using the default stylesheet. See
156<a href="qstylesheet.html#defaultSheet">QStyleSheet::defaultSheet</a>() for details. With certain strings that
157contain XML meta characters, the auto-rich text detection may
158fail, interpreting plain text incorrectly as rich text. In these
159rare cases, use <a href="qstylesheet.html#convertFromPlainText">QStyleSheet::convertFromPlainText</a>() to convert
160your plain text string to a visually equivalent rich text string
161or set the text format explicitly with <a href="#setTextFormat">setTextFormat</a>().
162<p> Note that the Microsoft Windows User Interface Guidelines
163recommend using the application name as the window's caption.
164<p> Below are more examples of how to use the static member functions.
165After these examples you will find an overview of the non-static
166member functions.
167<p> Exiting a program is part of its normal operation. If there is
168unsaved data the user probably should be asked if they want to
169save the data. For example:
170<p> <pre>
171 switch( QMessageBox::<a href="#information">information</a>( this, "Application name here",
172 "The document contains unsaved changes\n"
173 "Do you want to save the changes before exiting?",
174 "&amp;Save", "&amp;Discard", "Cancel",
175 0, // Enter == button 0
176 2 ) ) { // Escape == button 2
177 case 0: // Save clicked or Alt+S pressed or Enter pressed.
178 // save
179 break;
180 case 1: // Discard clicked or Alt+D pressed
181 // don't save but exit
182 break;
183 case 2: // Cancel clicked or Escape pressed
184 // don't exit
185 break;
186 }
187 </pre>
188
189<p> The Escape button cancels the entire exit operation, and pressing
190Enter causes the changes to be saved before the exit occurs.
191<p> Disk full errors are unusual and they certainly can be hard to
192correct. This example uses predefined buttons instead of
193hard-coded button texts:
194<p> <pre>
195 switch( QMessageBox::<a href="#warning">warning</a>( this, "Application name here",
196 "Could not save the user preferences,\n"
197 "because the disk is full. You can delete\n"
198 "some files and press Retry, or you can\n"
199 "abort the Save Preferences operation.",
200 QMessageBox::Retry | QMessageBox::Default,
201 QMessageBox::Abort | QMessageBox::Escape )) {
202 case QMessageBox::Retry: // Retry clicked or Enter pressed
203 // try again
204 break;
205 case QMessageBox::Abort: // Abort clicked or Escape pressed
206 // abort
207 break;
208 }
209 </pre>
210
211<p> The <a href="#critical">critical</a>() function should be reserved for critical errors. In
212this example errorDetails is a <a href="qstring.html">QString</a> or const char*, and QString
213is used to concatenate several strings:
214<p> <pre>
215 QMessageBox::<a href="#critical">critical</a>( 0, "Application name here",
216 QString("An internal error occurred. Please ") +
217 "call technical support at 1234-56789 and report\n"+
218 "these numbers:\n\n" + errorDetails +
219 "\n\nApplication will now exit." );
220 </pre>
221
222<p> In this example an OK button is displayed.
223<p> QMessageBox provides a very simple About box which displays an
224appropriate icon and the string you provide:
225<p> <pre>
226 QMessageBox::<a href="#about">about</a>( this, "About &lt;Application&gt;",
227 "&lt;Application&gt; is a &lt;one-paragraph blurb&gt;\n\n"
228 "Copyright 1991-2003 Such-and-such. "
229 "&lt;License words here.&gt;\n\n"
230 "For technical support, call 1234-56789 or see\n"
231 "http://www.such-and-such.com/Application/\n" );
232 </pre>
233
234<p> See <a href="#about">about</a>() for more information.
235<p> If you want your users to know that the application is built using
236Qt (so they know that you use high quality tools) you might like
237to add an "About Qt" menu option under the Help menu to invoke
238<a href="#aboutQt">aboutQt</a>().
239<p> If none of the standard message boxes is suitable, you can create a
240QMessageBox from scratch and use custom button texts:
241<p> <pre>
242 QMessageBox mb( "Application name here",
243 "Saving the file will overwrite the original file on the disk.\n"
244 "Do you really want to save?",
245 QMessageBox::<a href="#Icon-enum">Information</a>,
246 QMessageBox::Yes | QMessageBox::Default,
247 QMessageBox::No,
248 QMessageBox::Cancel | QMessageBox::Escape );
249 mb.<a href="#setButtonText">setButtonText</a>( QMessageBox::Yes, "Save" );
250 mb.<a href="#setButtonText">setButtonText</a>( QMessageBox::No, "Discard" );
251 switch( mb.<a href="qdialog.html#exec">exec</a>() ) {
252 case QMessageBox::Yes:
253 // save and exit
254 break;
255 case QMessageBox::No:
256 // exit without saving
257 break;
258 case QMessageBox::Cancel:
259 // don't save and don't exit
260 break;
261 }
262 </pre>
263
264<p> QMessageBox defines two enum types: Icon and an unnamed button type.
265Icon defines the <a href="#Icon-enum">Question</a>, <a href="#Icon-enum">Information</a>, <a href="#Icon-enum">Warning</a>, and <a href="#Icon-enum">Critical</a> icons for each GUI style. It is used by the constructor
266and by the static member functions <a href="#question">question</a>(), <a href="#information">information</a>(),
267<a href="#warning">warning</a>() and <a href="#critical">critical</a>(). A function called <a href="#standardIcon">standardIcon</a>() gives
268you access to the various icons.
269<p> The button types are:
270<ul>
271<li> Ok - the default for single-button message boxes
272<li> Cancel - note that this is <em>not</em> automatically Escape
273<li> Yes
274<li> No
275<li> Abort
276<li> Retry
277<li> Ignore
278<li> YesAll
279<li> NoAll
280</ul>
281<p> Button types can be combined with two modifiers by using OR, '|':
282<ul>
283<li> Default - makes pressing Enter equivalent to
284clicking this button. Normally used with Ok, Yes or similar.
285<li> Escape - makes pressing Escape equivalent to clicking this button.
286Normally used with Abort, Cancel or similar.
287</ul>
288<p> The <a href="#text">text</a>(), <a href="#icon">icon</a>() and <a href="#iconPixmap">iconPixmap</a>() functions provide access to the
289current text and pixmap of the message box. The <a href="#setText">setText</a>(), <a href="#setIcon">setIcon</a>()
290and <a href="#setIconPixmap">setIconPixmap</a>() let you change it. The difference between
291setIcon() and setIconPixmap() is that the former accepts a
292QMessageBox::Icon and can be used to set standard icons, whereas the
293latter accepts a <a href="qpixmap.html">QPixmap</a> and can be used to set custom icons.
294<p> <a href="#setButtonText">setButtonText</a>() and <a href="#buttonText">buttonText</a>() provide access to the buttons.
295<p> QMessageBox has no signals or slots.
296<p> <img src=qmsgbox-m.png> <img src=qmsgbox-w.png>
297<p> <p>See also <a href="qdialog.html">QDialog</a>, <a href="http://www.iarchitect.com/errormsg.htm
298 ">Isys on error messages</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Message Box</a>, and <a href="dialogs.html">Dialog Classes</a>.
299
300<hr><h2>Member Type Documentation</h2>
301<h3 class=fn><a name="Icon-enum"></a>QMessageBox::Icon</h3>
302
303<p> This enum has the following values:
304<ul>
305<li><tt>QMessageBox::NoIcon</tt> - the message box does not have any icon.
306<li><tt>QMessageBox::Question</tt> - an icon indicating that
307the message is asking a question.
308<li><tt>QMessageBox::Information</tt> - an icon indicating that
309the message is nothing out of the ordinary.
310<li><tt>QMessageBox::Warning</tt> - an icon indicating that the
311message is a warning, but can be dealt with.
312<li><tt>QMessageBox::Critical</tt> - an icon indicating that
313the message represents a critical problem.
314</ul><p>
315<hr><h2>Member Function Documentation</h2>
316<h3 class=fn><a name="QMessageBox"></a>QMessageBox::QMessageBox ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
317</h3>
318Constructs a message box with no text and a button with the label
319"OK".
320<p> If <em>parent</em> is 0, the message box becomes an application-global
321modal dialog box. If <em>parent</em> is a widget, the message box
322becomes modal relative to <em>parent</em>.
323<p> The <em>parent</em> and <em>name</em> arguments are passed to the <a href="qdialog.html">QDialog</a>
324constructor.
325
326<h3 class=fn><a name="QMessageBox-2"></a>QMessageBox::QMessageBox ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, <a href="qmessagebox.html#Icon-enum">Icon</a>&nbsp;icon, int&nbsp;button0, int&nbsp;button1, int&nbsp;button2, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;modal = TRUE, WFlags&nbsp;f = WStyle_DialogBorder )
327</h3>
328Constructs a message box with a <em>caption</em>, a <em>text</em>, an <em>icon</em>,
329and up to three buttons.
330<p> The <em>icon</em> must be one of the following:
331<ul>
332<li> QMessageBox::NoIcon
333<li> QMessageBox::Question
334<li> QMessageBox::Information
335<li> QMessageBox::Warning
336<li> QMessageBox::Critical
337</ul>
338<p> Each button, <em>button0</em>, <em>button1</em> and <em>button2</em>, can have one
339of the following values:
340<ul>
341<li> QMessageBox::NoButton
342<li> QMessageBox::Ok
343<li> QMessageBox::Cancel
344<li> QMessageBox::Yes
345<li> QMessageBox::No
346<li> QMessageBox::Abort
347<li> QMessageBox::Retry
348<li> QMessageBox::Ignore
349<li> QMessageBox::YesAll
350<li> QMessageBox::NoAll
351</ul>
352<p> Use QMessageBox::NoButton for the later parameters to have fewer
353than three buttons in your message box. If you don't specify any
354buttons at all, QMessageBox will provide an Ok button.
355<p> One of the buttons can be OR-ed with the <tt>QMessageBox::Default</tt>
356flag to make it the default button (clicked when Enter is
357pressed).
358<p> One of the buttons can be OR-ed with the <tt>QMessageBox::Escape</tt>
359flag to make it the cancel or close button (clicked when Escape is
360pressed).
361<p> Example:
362<pre>
363 QMessageBox mb( "Application Name",
364 "Hardware failure.\n\nDisk error detected\nDo you want to stop?",
365 QMessageBox::<a href="#Icon-enum">Question</a>,
366 QMessageBox::Yes | QMessageBox::Default,
367 QMessageBox::No | QMessageBox::Escape,
368 QMessageBox::<a href="qt.html#ButtonState-enum">NoButton</a> );
369 if ( mb.<a href="qdialog.html#exec">exec</a>() == QMessageBox::No )
370 // try again
371 </pre>
372
373<p> If <em>parent</em> is 0, the message box becomes an application-global
374modal dialog box. If <em>parent</em> is a widget, the message box
375becomes modal relative to <em>parent</em>.
376<p> If <em>modal</em> is TRUE the message box is modal; otherwise it
377is modeless.
378<p> The <em>parent</em>, <em>name</em>, <em>modal</em>, and <em>f</em> arguments are passed to
379the <a href="qdialog.html">QDialog</a> constructor.
380<p> <p>See also <a href="qwidget.html#caption-prop">caption</a>, <a href="#text-prop">text</a>, and <a href="#icon-prop">icon</a>.
381
382<h3 class=fn><a name="~QMessageBox"></a>QMessageBox::~QMessageBox ()
383</h3>
384Destroys the message box.
385
386<h3 class=fn>void <a name="about"></a>QMessageBox::about ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text )<tt> [static]</tt>
387</h3>
388Displays a simple about box with caption <em>caption</em> and text <em>text</em>. The about box's parent is <em>parent</em>.
389<p> <a href="#about">about</a>() looks for a suitable icon in four locations:
390<ol type=1>
391<li> It prefers <a href="qwidget.html#icon">parent->icon()</a> if that exists.
392<li> If not, it tries the top-level widget containing <em>parent</em>.
393<li> If that fails, it tries the <a href="qapplication.html#mainWidget">main widget.</a>
394<li> As a last resort it uses the Information icon.
395</ol>
396<p> The about box has a single button labelled "OK".
397<p> <p>See also <a href="qwidget.html#icon-prop">QWidget::icon</a> and <a href="qapplication.html#mainWidget">QApplication::mainWidget</a>().
398
399<p>Examples: <a href="qaction-application-example.html#x1137">action/application.cpp</a>, <a href="simple-application-example.html#x1555">application/application.cpp</a>, <a href="canvas-chart-example.html#x2886">chart/chartform.cpp</a>, <a href="helpviewer-example.html#x994">helpviewer/helpwindow.cpp</a>, <a href="mdi-example.html#x2036">mdi/application.cpp</a>, <a href="menu-example.html#x1874">menu/menu.cpp</a>, and <a href="themes-example.html#x330">themes/themes.cpp</a>.
400<h3 class=fn>void <a name="aboutQt"></a>QMessageBox::aboutQt ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption = QString::null )<tt> [static]</tt>
401</h3>
402Displays a simple message box about Qt, with caption <em>caption</em>
403and centered over <em>parent</em> (if <em>parent</em> is not 0). The message
404includes the version number of Qt being used by the application.
405<p> This is useful for inclusion in the Help menu of an application.
406See the examples/menu/menu.cpp example.
407<p> <a href="qapplication.html">QApplication</a> provides this functionality as a slot.
408<p> <p>See also <a href="qapplication.html#aboutQt">QApplication::aboutQt</a>().
409
410<p>Examples: <a href="qaction-application-example.html#x1138">action/application.cpp</a>, <a href="simple-application-example.html#x1556">application/application.cpp</a>, <a href="canvas-chart-example.html#x2887">chart/chartform.cpp</a>, <a href="helpviewer-example.html#x995">helpviewer/helpwindow.cpp</a>, <a href="menu-example.html#x1875">menu/menu.cpp</a>, <a href="themes-example.html#x331">themes/themes.cpp</a>, and <a href="trivial-nsplugin-example.html#x2736">trivial/trivial.cpp</a>.
411<h3 class=fn>void <a name="adjustSize"></a>QMessageBox::adjustSize ()<tt> [virtual]</tt>
412</h3>
413Adjusts the size of the message box to fit the contents just before
414<a href="qdialog.html#exec">QDialog::exec</a>() or <a href="qdialog.html#show">QDialog::show</a>() is called.
415<p> This function will not be called if the message box has been explicitly
416resized before showing it.
417
418<p>Reimplemented from <a href="qwidget.html#adjustSize">QWidget</a>.
419<h3 class=fn><a href="qstring.html">QString</a> <a name="buttonText"></a>QMessageBox::buttonText ( int&nbsp;button ) const
420</h3>
421Returns the text of the message box button <em>button</em>, or
422<a href="qstring.html#QString-null">QString::null</a> if the message box does not contain the button.
423<p> <p>See also <a href="#setButtonText">setButtonText</a>().
424
425<h3 class=fn>int <a name="critical"></a>QMessageBox::critical ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, int&nbsp;button0, int&nbsp;button1, int&nbsp;button2 = 0 )<tt> [static]</tt>
426</h3>
427Opens a critical message box with the caption <em>caption</em> and the
428text <em>text</em>. The dialog may have up to three buttons. Each of the
429button parameters, <em>button0</em>, <em>button1</em> and <em>button2</em> may be
430set to one of the following values:
431<p> <ul>
432<li> QMessageBox::NoButton
433<li> QMessageBox::Ok
434<li> QMessageBox::Cancel
435<li> QMessageBox::Yes
436<li> QMessageBox::No
437<li> QMessageBox::Abort
438<li> QMessageBox::Retry
439<li> QMessageBox::Ignore
440<li> QMessageBox::YesAll
441<li> QMessageBox::NoAll
442</ul>
443<p> If you don't want all three buttons, set the last button, or last
444two buttons to QMessageBox::NoButton.
445<p> One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one
446button can be OR-ed with <tt>QMessageBox::Escape</tt>.
447<p> Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)
448of the button that was clicked.
449<p> If <em>parent</em> is 0, the message box becomes an application-global
450modal dialog box. If <em>parent</em> is a widget, the message box
451becomes modal relative to <em>parent</em>.
452<p> <p>See also <a href="#information">information</a>(), <a href="#question">question</a>(), and <a href="#warning">warning</a>().
453
454<p>Examples: <a href="archivesearch-example.html#x478">network/archivesearch/archivedialog.ui.h</a>, <a href="ftpclient-example.html#x767">network/ftpclient/ftpmainwindow.ui.h</a>, <a href="process-example.html#x96">process/process.cpp</a>, and <a href="outliner-example.html#x1917">xml/outliner/outlinetree.cpp</a>.
455<h3 class=fn>int <a name="critical-2"></a>QMessageBox::critical ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button0Text = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button1Text = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button2Text = QString::null, int&nbsp;defaultButtonNumber = 0, int&nbsp;escapeButtonNumber = -1 )<tt> [static]</tt>
456</h3>
457This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
458<p> Displays a critical error message box with a caption, a text, and
4591, 2 or 3 buttons. Returns the number of the button that was
460clicked (0, 1 or 2).
461<p> <em>button0Text</em> is the text of the first button, and is optional.
462If <em>button0Text</em> is not supplied, "OK" (translated) will be used.
463<em>button1Text</em> is the text of the second button, and is optional,
464and <em>button2Text</em> is the text of the third button, and is
465optional. <em>defaultButtonNumber</em> (0, 1 or 2) is the index of the
466default button; pressing Return or Enter is the same as clicking
467the default button. It defaults to 0 (the first button). <em>escapeButtonNumber</em> is the index of the Escape button; pressing
468Escape is the same as clicking this button. It defaults to -1;
469supply 0, 1, or 2 to make pressing Escape equivalent to clicking
470the relevant button.
471<p> If <em>parent</em> is 0, the message box becomes an application-global
472modal dialog box. If <em>parent</em> is a widget, the message box
473becomes modal relative to <em>parent</em>.
474<p> <p>See also <a href="#information">information</a>(), <a href="#question">question</a>(), and <a href="#warning">warning</a>().
475
476<h3 class=fn><a href="qmessagebox.html#Icon-enum">Icon</a> <a name="icon"></a>QMessageBox::icon () const
477</h3><p>Returns the message box's icon.
478See the <a href="qmessagebox.html#icon-prop">"icon"</a> property for details.
479<h3 class=fn>const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;* <a name="iconPixmap"></a>QMessageBox::iconPixmap () const
480</h3><p>Returns the current icon.
481See the <a href="qmessagebox.html#iconPixmap-prop">"iconPixmap"</a> property for details.
482<h3 class=fn>int <a name="information"></a>QMessageBox::information ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, int&nbsp;button0, int&nbsp;button1 = 0, int&nbsp;button2 = 0 )<tt> [static]</tt>
483</h3>
484Opens an information message box with the caption <em>caption</em> and
485the text <em>text</em>. The dialog may have up to three buttons. Each of
486the buttons, <em>button0</em>, <em>button1</em> and <em>button2</em> may be set to
487one of the following values:
488<p> <ul>
489<li> QMessageBox::NoButton
490<li> QMessageBox::Ok
491<li> QMessageBox::Cancel
492<li> QMessageBox::Yes
493<li> QMessageBox::No
494<li> QMessageBox::Abort
495<li> QMessageBox::Retry
496<li> QMessageBox::Ignore
497<li> QMessageBox::YesAll
498<li> QMessageBox::NoAll
499</ul>
500<p> If you don't want all three buttons, set the last button, or last
501two buttons to QMessageBox::NoButton.
502<p> One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one
503button can be OR-ed with <tt>QMessageBox::Escape</tt>.
504<p> Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)
505of the button that was clicked.
506<p> If <em>parent</em> is 0, the message box becomes an application-global
507modal dialog box. If <em>parent</em> is a widget, the message box
508becomes modal relative to <em>parent</em>.
509<p> <p>See also <a href="#question">question</a>(), <a href="#warning">warning</a>(), and <a href="#critical">critical</a>().
510
511<p>Examples: <a href="qaction-application-example.html#x1139">action/application.cpp</a>, <a href="simple-application-example.html#x1557">application/application.cpp</a>, <a href="dirview-example.html#x1695">dirview/dirview.cpp</a>, <a href="fileiconview-example.html#x859">fileiconview/qfileiconview.cpp</a>, <a href="picture-example.html#x110">picture/picture.cpp</a>, <a href="qwerty-example.html#x373">qwerty/qwerty.cpp</a>, and <a href="qaxserver-example-simple.html#x2524">simple/main.cpp</a>.
512<h3 class=fn>int <a name="information-2"></a>QMessageBox::information ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button0Text = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button1Text = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button2Text = QString::null, int&nbsp;defaultButtonNumber = 0, int&nbsp;escapeButtonNumber = -1 )<tt> [static]</tt>
513</h3>
514This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
515<p> Displays an information message box with caption <em>caption</em>, text
516<em>text</em> and one, two or three buttons. Returns the index of the
517button that was clicked (0, 1 or 2).
518<p> <em>button0Text</em> is the text of the first button, and is optional.
519If <em>button0Text</em> is not supplied, "OK" (translated) will be used.
520<em>button1Text</em> is the text of the second button, and is optional.
521<em>button2Text</em> is the text of the third button, and is optional.
522<em>defaultButtonNumber</em> (0, 1 or 2) is the index of the default
523button; pressing Return or Enter is the same as clicking the
524default button. It defaults to 0 (the first button). <em>escapeButtonNumber</em> is the index of the Escape button; pressing
525Escape is the same as clicking this button. It defaults to -1;
526supply 0, 1 or 2 to make pressing Escape equivalent to clicking
527the relevant button.
528<p> If <em>parent</em> is 0, the message box becomes an application-global
529modal dialog box. If <em>parent</em> is a widget, the message box
530becomes modal relative to <em>parent</em>.
531<p> Note: If you do not specify an Escape button then if the Escape
532button is pressed then -1 will be returned. It is suggested that
533you specify an Escape button to prevent this from happening.
534<p> <p>See also <a href="#question">question</a>(), <a href="#warning">warning</a>(), and <a href="#critical">critical</a>().
535
536<h3 class=fn>int <a name="message"></a>QMessageBox::message ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;buttonText = QString::null, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const char * = 0 )<tt> [static]</tt>
537</h3>
538<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
539<p> Opens a modal message box directly using the specified parameters.
540<p> Please use <a href="#information">information</a>(), <a href="#warning">warning</a>(), <a href="#question">question</a>(), or <a href="#critical">critical</a>() instead.
541
542<p>Example: <a href="grapher-nsplugin-example.html#x2750">grapher/grapher.cpp</a>.
543<h3 class=fn>bool <a name="query"></a>QMessageBox::query ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;yesButtonText = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;noButtonText = QString::null, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const char * = 0 )<tt> [static]</tt>
544</h3>
545<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
546<p> Queries the user using a modal message box with two buttons.
547Note that <em>caption</em> is not always shown, it depends on the window manager.
548<p> Please use <a href="#information">information</a>(), <a href="#question">question</a>(), <a href="#warning">warning</a>(), or <a href="#critical">critical</a>() instead.
549
550<h3 class=fn>int <a name="question"></a>QMessageBox::question ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, int&nbsp;button0, int&nbsp;button1 = 0, int&nbsp;button2 = 0 )<tt> [static]</tt>
551</h3>
552Opens a question message box with the caption <em>caption</em> and the
553text <em>text</em>. The dialog may have up to three buttons. Each of the
554buttons, <em>button0</em>, <em>button1</em> and <em>button2</em> may be set to one
555of the following values:
556<p> <ul>
557<li> QMessageBox::NoButton
558<li> QMessageBox::Ok
559<li> QMessageBox::Cancel
560<li> QMessageBox::Yes
561<li> QMessageBox::No
562<li> QMessageBox::Abort
563<li> QMessageBox::Retry
564<li> QMessageBox::Ignore
565<li> QMessageBox::YesAll
566<li> QMessageBox::NoAll
567</ul>
568<p> If you don't want all three buttons, set the last button, or last
569two buttons to QMessageBox::NoButton.
570<p> One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one
571button can be OR-ed with <tt>QMessageBox::Escape</tt>.
572<p> Returns the identity (QMessageBox::Yes, or QMessageBox::No, etc.)
573of the button that was clicked.
574<p> If <em>parent</em> is 0, the message box becomes an application-global
575modal dialog box. If <em>parent</em> is a widget, the message box
576becomes modal relative to <em>parent</em>.
577<p> <p>See also <a href="#information">information</a>(), <a href="#warning">warning</a>(), and <a href="#critical">critical</a>().
578
579<h3 class=fn>int <a name="question-2"></a>QMessageBox::question ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button0Text = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button1Text = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button2Text = QString::null, int&nbsp;defaultButtonNumber = 0, int&nbsp;escapeButtonNumber = -1 )<tt> [static]</tt>
580</h3>
581This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
582<p> Displays a question message box with caption <em>caption</em>, text <em>text</em> and one, two or three buttons. Returns the index of the
583button that was clicked (0, 1 or 2).
584<p> <em>button0Text</em> is the text of the first button, and is optional.
585If <em>button0Text</em> is not supplied, "OK" (translated) will be used.
586<em>button1Text</em> is the text of the second button, and is optional.
587<em>button2Text</em> is the text of the third button, and is optional.
588<em>defaultButtonNumber</em> (0, 1 or 2) is the index of the default
589button; pressing Return or Enter is the same as clicking the
590default button. It defaults to 0 (the first button). <em>escapeButtonNumber</em> is the index of the Escape button; pressing
591Escape is the same as clicking this button. It defaults to -1;
592supply 0, 1 or 2 to make pressing Escape equivalent to clicking
593the relevant button.
594<p> If <em>parent</em> is 0, the message box becomes an application-global
595modal dialog box. If <em>parent</em> is a widget, the message box
596becomes modal relative to <em>parent</em>.
597<p> Note: If you do not specify an Escape button then if the Escape
598button is pressed then -1 will be returned. It is suggested that
599you specify an Escape button to prevent this from happening.
600<p> <p>See also <a href="#information">information</a>(), <a href="#warning">warning</a>(), and <a href="#critical">critical</a>().
601
602<h3 class=fn>void <a name="setButtonText"></a>QMessageBox::setButtonText ( int&nbsp;button, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text )
603</h3>
604Sets the text of the message box button <em>button</em> to <em>text</em>.
605Setting the text of a button that is not in the message box is
606silently ignored.
607<p> <p>See also <a href="#buttonText">buttonText</a>().
608
609<h3 class=fn>void <a name="setIcon"></a>QMessageBox::setIcon ( <a href="qmessagebox.html#Icon-enum">Icon</a> )
610</h3><p>Sets the message box's icon.
611See the <a href="qmessagebox.html#icon-prop">"icon"</a> property for details.
612<h3 class=fn>void <a name="setIconPixmap"></a>QMessageBox::setIconPixmap ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp; )
613</h3><p>Sets the current icon.
614See the <a href="qmessagebox.html#iconPixmap-prop">"iconPixmap"</a> property for details.
615<h3 class=fn>void <a name="setText"></a>QMessageBox::setText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )
616</h3><p>Sets the message box text to be displayed.
617See the <a href="qmessagebox.html#text-prop">"text"</a> property for details.
618<h3 class=fn>void <a name="setTextFormat"></a>QMessageBox::setTextFormat ( <a href="qt.html#TextFormat-enum">TextFormat</a> )
619</h3><p>Sets the format of the text displayed by the message box.
620See the <a href="qmessagebox.html#textFormat-prop">"textFormat"</a> property for details.
621<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="standardIcon"></a>QMessageBox::standardIcon ( <a href="qmessagebox.html#Icon-enum">Icon</a>&nbsp;icon )<tt> [static]</tt>
622</h3>
623Returns the pixmap used for a standard icon. This allows the
624pixmaps to be used in more complex message boxes. <em>icon</em>
625specifies the required icon, e.g. QMessageBox::Question,
626QMessageBox::Information, QMessageBox::Warning or
627QMessageBox::Critical.
628
629<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="standardIcon-2"></a>QMessageBox::standardIcon ( <a href="qmessagebox.html#Icon-enum">Icon</a>&nbsp;icon, <a href="qt.html#GUIStyle-enum">GUIStyle</a>&nbsp;style )<tt> [static]</tt>
630</h3>
631<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
632<p> Returns the pixmap used for a standard icon. This
633allows the pixmaps to be used in more complex message boxes.
634<em>icon</em> specifies the required icon, e.g. QMessageBox::Information,
635QMessageBox::Warning or QMessageBox::Critical.
636<p> <em>style</em> is unused.
637
638<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QMessageBox::text () const
639</h3><p>Returns the message box text to be displayed.
640See the <a href="qmessagebox.html#text-prop">"text"</a> property for details.
641<h3 class=fn><a href="qt.html#TextFormat-enum">TextFormat</a> <a name="textFormat"></a>QMessageBox::textFormat () const
642</h3><p>Returns the format of the text displayed by the message box.
643See the <a href="qmessagebox.html#textFormat-prop">"textFormat"</a> property for details.
644<h3 class=fn>int <a name="warning"></a>QMessageBox::warning ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, int&nbsp;button0, int&nbsp;button1, int&nbsp;button2 = 0 )<tt> [static]</tt>
645</h3>
646Opens a warning message box with the caption <em>caption</em> and the
647text <em>text</em>. The dialog may have up to three buttons. Each of the
648button parameters, <em>button0</em>, <em>button1</em> and <em>button2</em> may be
649set to one of the following values:
650<p> <ul>
651<li> QMessageBox::NoButton
652<li> QMessageBox::Ok
653<li> QMessageBox::Cancel
654<li> QMessageBox::Yes
655<li> QMessageBox::No
656<li> QMessageBox::Abort
657<li> QMessageBox::Retry
658<li> QMessageBox::Ignore
659<li> QMessageBox::YesAll
660<li> QMessageBox::NoAll
661</ul>
662<p> If you don't want all three buttons, set the last button, or last
663two buttons to QMessageBox::NoButton.
664<p> One button can be OR-ed with <tt>QMessageBox::Default</tt>, and one
665button can be OR-ed with <tt>QMessageBox::Escape</tt>.
666<p> Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)
667of the button that was clicked.
668<p> If <em>parent</em> is 0, the message box becomes an application-global
669modal dialog box. If <em>parent</em> is a widget, the message box
670becomes modal relative to <em>parent</em>.
671<p> <p>See also <a href="#information">information</a>(), <a href="#question">question</a>(), and <a href="#critical">critical</a>().
672
673<p>Examples: <a href="tutorial2-05.html#x2566">chart/chartform.cpp</a>, <a href="i18n-example.html#x1940">i18n/main.cpp</a>, <a href="mail-example.html#x708">network/mail/smtp.cpp</a>, <a href="qwerty-example.html#x374">qwerty/qwerty.cpp</a>, <a href="showimg-example.html#x1333">showimg/showimg.cpp</a>, and <a href="sound-example.html#x2812">sound/sound.cpp</a>.
674<h3 class=fn>int <a name="warning-2"></a>QMessageBox::warning ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button0Text = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button1Text = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;button2Text = QString::null, int&nbsp;defaultButtonNumber = 0, int&nbsp;escapeButtonNumber = -1 )<tt> [static]</tt>
675</h3>
676This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
677<p> Displays a warning message box with a caption, a text, and 1, 2 or
6783 buttons. Returns the number of the button that was clicked (0,
6791, or 2).
680<p> <em>button0Text</em> is the text of the first button, and is optional.
681If <em>button0Text</em> is not supplied, "OK" (translated) will be used.
682<em>button1Text</em> is the text of the second button, and is optional,
683and <em>button2Text</em> is the text of the third button, and is
684optional. <em>defaultButtonNumber</em> (0, 1 or 2) is the index of the
685default button; pressing Return or Enter is the same as clicking
686the default button. It defaults to 0 (the first button). <em>escapeButtonNumber</em> is the index of the Escape button; pressing
687Escape is the same as clicking this button. It defaults to -1;
688supply 0, 1, or 2 to make pressing Escape equivalent to clicking
689the relevant button.
690<p> If <em>parent</em> is 0, the message box becomes an application-global
691modal dialog box. If <em>parent</em> is a widget, the message box
692becomes modal relative to <em>parent</em>.
693<p> Note: If you do not specify an Escape button then if the Escape
694button is pressed then -1 will be returned. It is suggested that
695you specify an Escape button to prevent this from happening.
696<p> <p>See also <a href="#information">information</a>(), <a href="#question">question</a>(), and <a href="#critical">critical</a>().
697
698<hr><h2>Property Documentation</h2>
699<h3 class=fn><a href="qmessagebox.html#Icon-enum">Icon</a> <a name="icon-prop"></a>icon</h3>
700<p>This property holds the message box's icon.
701<p>The icon of the message box can be one of the following predefined
702icons:
703<ul>
704<li> QMessageBox::NoIcon
705<li> QMessageBox::Question
706<li> QMessageBox::Information
707<li> QMessageBox::Warning
708<li> QMessageBox::Critical
709</ul>
710<p> The actual pixmap used for displaying the icon depends on the
711current <a href="qwidget.html#style">GUI style</a>. You can also set
712a custom pixmap icon using the <a href="#iconPixmap-prop">QMessageBox::iconPixmap</a>
713property. The default icon is QMessageBox::NoIcon.
714<p> <p>See also <a href="#iconPixmap-prop">iconPixmap</a>.
715
716<p>Set this property's value with <a href="#setIcon">setIcon</a>() and get this property's value with <a href="#icon">icon</a>().
717<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="iconPixmap-prop"></a>iconPixmap</h3>
718<p>This property holds the current icon.
719<p>The icon currently used by the message box. Note that it's often
720hard to draw one pixmap that looks appropriate in both <a href="motif-extension.html#Motif">Motif</a> and
721Windows GUI styles; you may want to draw two pixmaps.
722<p> <p>See also <a href="#icon-prop">icon</a>.
723
724<p>Set this property's value with <a href="#setIconPixmap">setIconPixmap</a>() and get this property's value with <a href="#iconPixmap">iconPixmap</a>().
725<h3 class=fn><a href="qstring.html">QString</a> <a name="text-prop"></a>text</h3>
726<p>This property holds the message box text to be displayed.
727<p>The text will be interpreted either as a plain text or as rich
728text, depending on the text format setting (<a href="#textFormat-prop">QMessageBox::textFormat</a>). The default setting is <a href="qt.html#TextFormat-enum">AutoText</a>, i.e.
729the message box will try to auto-detect the format of the text.
730<p> The default value of this property is <a href="qstring.html#QString-null">QString::null</a>.
731<p> <p>See also <a href="#textFormat-prop">textFormat</a>.
732
733<p>Set this property's value with <a href="#setText">setText</a>() and get this property's value with <a href="#text">text</a>().
734<h3 class=fn><a href="qt.html#TextFormat-enum">TextFormat</a> <a name="textFormat-prop"></a>textFormat</h3>
735<p>This property holds the format of the text displayed by the message box.
736<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.
737<p> The default format is <a href="qt.html#TextFormat-enum">AutoText</a>.
738<p> <p>See also <a href="#text-prop">text</a>.
739
740<p>Set this property's value with <a href="#setTextFormat">setTextFormat</a>() and get this property's value with <a href="#textFormat">textFormat</a>().
741<!-- eof -->
742<hr><p>
743This file is part of the <a href="index.html">Qt toolkit</a>.
744Copyright &copy; 1995-2007
745<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
746<table width=100% cellspacing=0 border=0><tr>
747<td>Copyright &copy; 2007
748<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
749<td align=right><div align=right>Qt 3.3.8</div>
750</table></div></address></body>
751</html>
Note: See TracBrowser for help on using the repository browser.