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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QMessageBox Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QMessageBox Class Reference</h1><br clear="all">
<p>
Displays a brief message, an icon, and some buttons.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qmessagebox-h.html">qmessagebox.h</a>></code>
<p>
Inherits <a href="qdialog.html">QDialog</a>.
<p><a href="qmessagebox-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn">enum<a href="#Icon"><b>Icon</b></a>{NoIcon=0, Information=1, Warning=2, Critical=3}</div>
<li><div class="fn"><a href="#802f7f"><b>QMessageBox</b></a>(QWidget*parent=0, constchar*name=0)</div>
<li><div class="fn"><a href="#3da42e"><b>QMessageBox</b></a>(constQString&caption, constQString&text, Iconicon, intbutton0, intbutton1, intbutton2, QWidget*parent=0, constchar*name=0, boolmodal=TRUE, WFlagsf=WStyle_DialogBorder)</div>
<li><div class="fn"><a href="#5955a6"><b>~QMessageBox</b></a>()</div>
<li><div class="fn">enum{NoButton=0, Ok=1, Cancel=2, Yes=3, No=4, Abort=5, Retry=6, Ignore=7, ButtonMask=0x07, Default=0x100, Escape=0x200, FlagMask=0x300}</div>
<li><div class="fn">QString<a href="#163468"><b>text</b></a>()const</div>
<li><div class="fn">void<a href="#bc19a7"><b>setText</b></a>(constQString&)</div>
<li><div class="fn">Icon<a href="#59436e"><b>icon</b></a>()const</div>
<li><div class="fn">void<a href="#c37e48"><b>setIcon</b></a>(Icon)</div>
<li><div class="fn">constQPixmap*<a href="#688e6a"><b>iconPixmap</b></a>()const</div>
<li><div class="fn">void<a href="#db0550"><b>setIconPixmap</b></a>(constQPixmap&)</div>
<li><div class="fn">QString<a href="#9c8790"><b>buttonText</b></a>(intbutton)const</div>
<li><div class="fn">void<a href="#5e8cf5"><b>setButtonText</b></a>(intbutton, constQString&)</div>
<li><div class="fn">virtualvoid<a href="#aacc15"><b>adjustSize</b></a>()</div>
<li><div class="fn">TextFormat<a href="#1c2c0b"><b>textFormat</b></a>()const</div>
<li><div class="fn">void<a href="#3c0699"><b>setTextFormat</b></a>(TextFormat)</div>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class="fn">int<a href="#66b7c8"><b>information</b></a>(QWidget*parent, constQString&caption, constQString&text, intbutton0, intbutton1=0, intbutton2=0)</div>
<li><div class="fn">int<a href="#740f88"><b>information</b></a>(QWidget*parent, constQString&caption, constQString&text, constQString&button0Text=QString::null, constQString&button1Text=QString::null, constQString&button2Text=QString::null, intdefaultButtonNumber=0, intescapeButtonNumber=-1)</div>
<li><div class="fn">int<a href="#e2f1b1"><b>warning</b></a>(QWidget*parent, constQString&caption, constQString&text, intbutton0, intbutton1, intbutton2=0)</div>
<li><div class="fn">int<a href="#63edba"><b>warning</b></a>(QWidget*parent, constQString&caption, constQString&text, constQString&button0Text=QString::null, constQString&button1Text=QString::null, constQString&button2Text=QString::null, intdefaultButtonNumber=0, intescapeButtonNumber=-1)</div>
<li><div class="fn">int<a href="#f0902b"><b>critical</b></a>(QWidget*parent, constQString&caption, constQString&text, intbutton0, intbutton1, intbutton2=0)</div>
<li><div class="fn">int<a href="#196e77"><b>critical</b></a>(QWidget*parent, constQString&caption, constQString&text, constQString&button0Text=QString::null, constQString&button1Text=QString::null, constQString&button2Text=QString::null, intdefaultButtonNumber=0, intescapeButtonNumber=-1)</div>
<li><div class="fn">void<a href="#f6c3cd"><b>about</b></a>(QWidget*parent, constQString&caption, constQString&text)</div>
<li><div class="fn">void<a href="#b72270"><b>aboutQt</b></a>(QWidget*parent, constQString&caption=QString::null)</div>
<li><div class="fn">QPixmap<a href="#50866f"><b>standardIcon</b></a>(Iconicon, GUIStylestyle)</div>
</ul>
<h2>Properties</h2>
<table border=1 cellpadding=3 cellspacing=0>
<tr><th>Type<th>Name<th>READ<th>WRITE<th>Options
<tr><td>QString<td>text<td>text<td>setText<td>
<tr><td>Icon<td>icon<td>icon<td>setIcon<td>
<tr><td>QPixmap<td>iconPixmap<td>iconPixmap<td>setIconPixmap<td>
<tr><td>TextFormat<td>textFormat<td>textFormat<td>setTextFormat<td>
</table>
<hr><h2><a name="details"></a>Detailed Description</h2>
Displays a brief message, an icon, and some buttons.
<p>
A message box is a modal dialog that displays an icon, a text and up to
three push buttons. It's used for simple messages and questions.
<p>QMessageBox provides a range of different messages, arranged roughly
along two axes: Severity and complexity.
<p>Severity is
<ul>
<li> <code>Information</code> - for message boxes that are part of normal operation
<li> <code>Warning</code> - for message boxes that tell the user about unusual errors
<li> <code>Critical</code> - as Warning, but for critical errors
</ul>
<p>The message box has a different icon for each of the severity levels.
<p>Complexity is one button (Ok) for a simple messages, or two or even
three buttons for questions.
<p>There are static functions that let you do most of the common jobs,
for example:
<p>If a program is unable to find a supporting file, but can do perfectly
well without:
<p><pre> <a href="#66b7c8">QMessageBox::information</a>( this, "Application name",
"Unable to find the user preferences file.\n"
"The factory default will be used instead." );
</pre>
<p><a href="#63edba">warning</a>() can be used to tell the user about unusual errors, or
errors which can't be easily fixed:
<p><pre> switch( <a href="#63edba">QMessageBox::warning</a>( this, "Application name",
"Could not connect to the <mumble> server.\n"
"This program can't function correctly "
"without the server.\n\n",
"Try again", "Quit", 0,
0, 1 );
case 0: // Try again or Enter
// try again
break;
case 1: // Quit or Escape
// exit
break;
}
</pre>
<p>Finally,
<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
<a href="qstylesheet.html#50ded7">QStyleSheet::defaultSheet</a>() for details. With certain strings that
contain XML meta characters, the auto-rich text detection may fail,
interpreting plain text falsely as rich text. In these rare cases,
use <a href="qstylesheet.html#e1e9e8">QStyleSheet::convertFromPlainText</a>() to convert your plain text
string to a visually equivalent rich text string or set the text
format explicitly with <a href="#3c0699">setTextFormat</a>().
<p>Here are some examples of how to use the static member functions.
After these examples you will find an overview of the non-static
member functions.
<p>If a program is unable to find a supporting file, it may perhaps do:
<p><pre> <a href="#66b7c8">QMessageBox::information</a>( this, "Application name here",
"Unable to find the file \"index.html\".\n"
"The factory default will be used instead." );
</pre>
<p>The Microsoft Windows User Interface Guidelines strongly recommends
using the application name as window caption. The message box has
just one button, OK, and its text tells the user both what happened
and what the program will do about it. Since the application is
able to make do, the message box is just information, not a warning
or a critical error.
<p>Exiting a program is part of its normal operation, and if there are
unsaved data the user probably should be asked what to do, for
example like this:
<p><pre> switch( <a href="#66b7c8">QMessageBox::information</a>( this, "Application name here",
"The document contains unsaved work\n"
"Do you want to save it before exiting?",
"&Save", "&Don't Save", "&Cancel",
0, // Enter == button 0
2 ) ) { // Escape == button 2
case 0: // Save clicked, Alt-S or Enter pressed.
// save
break;
case 1: // Don't Save clicked or Alt-D pressed
// don't save but exit
break;
case 2: // Cancel clicked, Alt-C or Escape pressed
// don't exit
break;
}
</pre>
<p>Again, the application name is used as window caption, as Microsoft
recommends. The Escape button cancels the entire Exit operation,
and Enter/Return saves the document and exits.
<p>Disk full errors are unusual (in a perfect world, they are) and they
certainly can be hard to correct. This example uses predefined buttons
instead of hardcoded button texts:
<p><pre> switch( <a href="#63edba">QMessageBox::warning</a>( this, "Application name here",
"Could not save the 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 or Enter
// try again
break;
case QMessageBox::Abort: // Abort or Cancel
// abort
break;
}
</pre>
<p>The <a href="#196e77">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 QString
is used to concatenate several strings:
<p><pre> <a href="#196e77">QMessageBox::critical</a>( 0, "Application name here",
<a href="qstring.html">QString</a>("An internal error occurred. Please ") +
"call technical support at 123456789 and report\n"+
"these numbers:\n\n" + errorDetails +
"\n\n<Application> will now exit." );
</pre>
<p>QMessageBox provides a very simple About box, which displays an
appropriate icon and the string you give it:
<p><pre> <a href="#f6c3cd">QMessageBox::about</a>( this, "About <Application>",
"<Application> is a <one-paragraph blurb>\n\n"
"Copyright 1951-1997 Such-and-such. "
"<License words here.>\n\n"
"For technical support, call 123456789 or see\n"
"http://www.such-and-such.com/Application/\n" );
</pre>
<p>See <a href="#f6c3cd">about</a>() for more information.
<p>Finally, you can make a QMessageBox from scratch and set custom
button texts:
<p><pre> <a href="qmessagebox.html">QMessageBox</a> mb( "Application name here",
"Saving the file will overwrite the old file on disk.\n"
"Do you really want to save?",
QMessageBox::Information,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No,
QMessageBox::Cancel | QMessageBox::Escape );
mb.<a href="#5e8cf5">setButtonText</a>( QMessageBox::Yes, "Save" );
mb.<a href="#5e8cf5">setButtonText</a>( QMessageBox::No, "Don't Save" );
switch( mb.<a href="qdialog.html#0beb1a">exec</a>() ) {
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, <a href="#Icon">Icon</a> and an unnamed button type.
Icon defines the <code>Information, Warning</code> and <code>Critical</code> icons for
each GUI style. It is used by the constructor, by the static member
functions <a href="#66b7c8">information</a>(), warning() and critical(), and there is a
function called <a href="#50866f">standardIcon</a>() which gives you access to the various
icons.
<p>The button types are:
<ul>
<li> <code>Ok</code> - the default for single-button message boxes
<li> <code>Cancel</code> - note that this is <em>not</em> automatically Escape
<li> <code>Yes</code>
<li> <code>No</code>
<li> <code>Abort</code>
<li> <code>Retry</code>
<li> <code>Ignore</code>
</ul>
<p>Button types can be combined with two modifiers by using OR:
<ul>
<li> <code>Default</code> - makes pressing Enter or Return be equivalent with
clicking this button. Normally used with Ok, Yes or similar.
<li> <code>Escape</code> - makes pressing Escape be equivalent with this button.
Normally used with Abort, Cancel or similar.
</ul>
<p>The <a href="#163468">text</a>(), <a href="#59436e">icon</a>() and <a href="#688e6a">iconPixmap</a>() functions provide access to the
current text and pixmap of a message box, and <a href="#bc19a7">setText</a>(), <a href="#7b9199">setIcon</a>()
and <a href="#db0550">setIconPixmap</a>() lets you change it. The difference between
setIcon() and setIconPixmap() is that the former accepts a
<a href="#Icon">QMessageBox::Icon</a> and can it be used to set standard icons while the
latter accepts a <a href="qpixmap.html">QPixmap</a> and can be used to set custom icons.
<p><a href="#5e8cf5">setButtonText</a>() and <a href="#9c8790">buttonText</a>() provide access to the buttons.
<p>QMessageBox has no signals or slots.
<p><img src=qmsgbox-m.png> <img src=qmsgbox-w.png>
<p>See also <a href="qdialog.html">QDialog</a>, <a href="http://www.iarchitect.com/errormsg.htm">Isys on error messages,</a> and <a href="guibooks.html#fowler">GUI Design Handbook: Message Box.</a>
<hr><h2>Member Type Documentation</h2>
<h3 class="fn"><a name="Icon">QMessageBox::Icon</a></h3>
This type includes the following values:
<ul>
<li> <code>QMessageBox::NoIcon</code>
<li> <code>QMessageBox::Information</code>
<li> <code>QMessageBox::Warning</code>
<li> <code>QMessageBox::Critical</code>
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="802f7f"></a>QMessageBox::QMessageBox(<a href="qwidget.html">QWidget</a>*parent=0, constchar*name=0)</h3>
<p>Constructs a message box with no text and a button with the text "OK".
<p>If <em>parent</em> is 0, then the message box becomes an application-global
modal dialog box. If <em>parent</em> is a widget, the message box becomes
modal relative to <em>parent.</em>
<p>The <em>parent</em> and <em>name</em> arguments are passed to the <a href="qdialog.html">QDialog</a> constructor.
<h3 class="fn"><a name="3da42e"></a>QMessageBox::QMessageBox(const<a href="qstring.html">QString</a>&caption, const<a href="qstring.html">QString</a>&text, <a href="qmessagebox.html#Icon">Icon</a>icon, intbutton0, intbutton1, intbutton2, <a href="qwidget.html">QWidget</a>*parent=0, constchar*name=0, boolmodal=TRUE, WFlagsf=WStyle_DialogBorder)</h3>
<p>Constructs a message box with a <em>caption,</em> a <em>text,</em> an <em>icon</em> and up
to three buttons.
<p>The <em>icon</em> must be one of:
<ul>
<li> <code>QMessageBox::NoIcon</code>
<li> <code>QMessageBox::Information</code>
<li> <code>QMessageBox::Warning</code>
<li> <code>QMessageBox::Critical</code>
</ul>
<p>Each button can have one of the following values:
<ul>
<li><code>QMessageBox::NoButton</code>
<li><code>QMessageBox::Ok</code>
<li><code>QMessageBox::Cancel</code>
<li><code>QMessageBox::Yes</code>
<li><code>QMessageBox::No</code>
<li><code>QMessageBox::Abort</code>
<li><code>QMessageBox::Retry</code>
<li><code>QMessageBox::Ignore</code>
</ul>
<p>Use QMessageBox::NoButton for the later parameters to have less than
three buttons in your message box.
<p>One of the buttons can be combined with the <code>QMessageBox::Default</code> flag
to make a default button.
<p>One of the buttons can be combined with the <code>QMessageBox::Escape</code> flag
to make an escape option. Hitting the Esc key on the keyboard has
the same effect as clicking this button with the mouse.
<p>Example:
<pre> <a href="qmessagebox.html">QMessageBox</a> mb( "Hardware failure",
"Disk error detected\nDo you want to stop?",
QMessageBox::NoIcon,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::No | QMessageBox::Escape );
if ( mb.<a href="qdialog.html#0beb1a">exec</a>() == QMessageBox::No )
// try again
</pre>
<p>If <em>parent</em> is 0, then the message box becomes an application-global
modal dialog box. If <em>parent</em> is a widget, the message box becomes
modal relative to <em>parent.</em>
<p>If <em>modal</em> is TRUE the message becomes modal, otherwise it becomes
modeless.
<p>The <em>parent, name, modal</em> and <em>f</em> arguments are passed to the
<a href="qdialog.html">QDialog</a> constructor.
<p>See also <a href="qwidget.html#d6a291">setCaption</a>(), <a href="#bc19a7">setText</a>() and <a href="#7b9199">setIcon</a>().
<h3 class="fn"><a name="5955a6"></a>QMessageBox::~QMessageBox()</h3>
<p>Destructs the message box.
<h3 class="fn">void<a name="f6c3cd"></a>QMessageBox::about(<a href="qwidget.html">QWidget</a>*parent, const<a href="qstring.html">QString</a>&caption, const<a href="qstring.html">QString</a>&text) <code>[static]</code></h3>
<p>Displays a simple about box with window caption <em>caption</em> and
body text <em>text.</em>
<p>about() looks for a suitable icon for the box in four locations:
<ol> <li>It prefers <a href="qwidget.html#126b68">parent->icon()</a>
if that exists. <li>If not, it tries the top level widget
containing <em>parent</em> <li>If that too fails, it tries the <a href="qapplication.html#85380c">main widget.</a> <li>As a last
resort it uses the Information icon. </ol>
<p>The about box has a single button labelled OK.
<p>See also <a href="qwidget.html#126b68">QWidget::icon</a>() and <a href="qapplication.html#85380c">QApplication::mainWidget</a>().
<p>Examples:
<a href="menu-menu-cpp.html#QMessageBox::about">menu/menu.cpp</a>
<h3 class="fn">void<a name="b72270"></a>QMessageBox::aboutQt(<a href="qwidget.html">QWidget</a>*parent, const<a href="qstring.html">QString</a>&caption=QString::null) <code>[static]</code></h3>
<p>Displays a simple message box about Qt, with window caption <em>caption</em> and optionally centered over <em>parent.</em> The message includes
the version number of Qt being used by the application.
<p>This is neat for inclusion into the Help menu. See the menu.cpp
example.
<p>Examples:
<a href="menu-menu-cpp.html#QMessageBox::aboutQt">menu/menu.cpp</a>
<a href="trivial-trivial-cpp.html#QMessageBox::aboutQt">trivial/trivial.cpp</a>
<h3 class="fn">void<a name="aacc15"></a>QMessageBox::adjustSize() <code>[virtual]</code></h3>
<p>Adjusts the size of the message box to fit the contents just before
<a href="qdialog.html#0beb1a">QDialog::exec</a>() or <a href="qdialog.html#bfe29c">QDialog::show</a>() is called.
<p>This function will not be called if the message box has been explicitly
resized before showing it.
<p>Reimplemented from <a href="qwidget.html#2ec710">QWidget.</a>
<h3 class="fn"><a href="qstring.html">QString</a><a name="9c8790"></a>QMessageBox::buttonText(intbutton)const</h3>
<p>Returns the text of the message box button <em>button,</em> or null if the
message box does not contain the button.
<p>See also <a href="#5e8cf5">setButtonText</a>().
<h3 class="fn">int<a name="196e77"></a>QMessageBox::critical(<a href="qwidget.html">QWidget</a>*parent, const<a href="qstring.html">QString</a>&caption, const<a href="qstring.html">QString</a>&text, const<a href="qstring.html">QString</a>&button0Text=QString::null, const<a href="qstring.html">QString</a>&button1Text=QString::null, const<a href="qstring.html">QString</a>&button2Text=QString::null, intdefaultButtonNumber=0, intescapeButtonNumber=-1) <code>[static]</code></h3>
<p>Displays a critical error message box with a caption, a text and
1-3 buttons. Returns the number of the button that was clicked
(0, 1 or 2).
<p><em>button0Text</em> is the text of the first button and is optional. If
<em>button0Text</em> is not supplied, "OK" (translated) will be used.
<em>button1Text</em> is the text of the second button and is optional, and
<em>button2Text</em> is the text of the third button and is optional. <em>defaultbuttonNumber</em> (0-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). <em>escapeButtonNumber</em> is the
index of the Escape button; pressing Escape is the same as clicking
this button. It defaults to -1 (pressing Escape does nothing);
supply 0, 1 or 2 to make pressing Escape be equivalent with clicking
the relevant button.
<p>If <em>parent</em> is 0, then the message box becomes an application-global
modal dialog box. If <em>parent</em> is a widget, the message box becomes
modal relative to <em>parent.</em>
<p>See also <a href="#66b7c8">information</a>() and <a href="#63edba">warning</a>().
<h3 class="fn">int<a name="f0902b"></a>QMessageBox::critical(<a href="qwidget.html">QWidget</a>*parent, const<a href="qstring.html">QString</a>&caption, const<a href="qstring.html">QString</a>&text, intbutton0, intbutton1, intbutton2=0) <code>[static]</code></h3>
<p>Opens a critical message box with a caption, a text and up to three
buttons. Returns the identifier of the button that was clicked.
<p>If <em>parent</em> is 0, then the message box becomes an application-global
modal dialog box. If <em>parent</em> is a widget, the message box becomes
modal relative to <em>parent.</em>
<p>See also <a href="#66b7c8">information</a>() and <a href="#63edba">warning</a>().
<h3 class="fn">QMessageBox::Icon<a name="59436e"></a>QMessageBox::icon()const</h3>
<p>Returns the icon of the message box.
<p>See also <a href="#7b9199">setIcon</a>() and <a href="#688e6a">iconPixmap</a>().
<h3 class="fn">const<a href="qpixmap.html">QPixmap</a>*<a name="688e6a"></a>QMessageBox::iconPixmap()const</h3>
<p>Returns the icon pixmap of the message box.
<p>Example:
<pre> <a href="qmessagebox.html">QMessageBox</a> mb(...);
mb.<a href="#7b9199">setIcon</a>( QMessageBox::Warning );
mb.<a href="#688e6a">iconPixmap</a>(); // returns the warning icon pixmap
</pre>
<p>See also <a href="#db0550">setIconPixmap</a>() and <a href="#59436e">icon</a>().
<h3 class="fn">int<a name="740f88"></a>QMessageBox::information(<a href="qwidget.html">QWidget</a>*parent, const<a href="qstring.html">QString</a>&caption, const<a href="qstring.html">QString</a>&text, const<a href="qstring.html">QString</a>&button0Text=QString::null, const<a href="qstring.html">QString</a>&button1Text=QString::null, const<a href="qstring.html">QString</a>&button2Text=QString::null, intdefaultButtonNumber=0, intescapeButtonNumber=-1) <code>[static]</code></h3>
<p>Displays an information message box with a caption, a text and
1-3 buttons. Returns the number of the button that was clicked
(0, 1 or 2).
<p><em>button0Text</em> is the text of the first button and is optional. If
<em>button0Text</em> is not supplied, "OK" (translated) will be used.
<em>button1Text</em> is the text of the second button and is optional.
<em>button2Text</em> is the text of the third button and is optional. <em>defaultbuttonNumber</em> (0-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). <em>escapeButtonNumber</em> is the
index of the Escape button; pressing Escape is the same as clicking
this button. It defaults to -1 (pressing Escape does nothing);
supply 0, 1 or 2 to make pressing Escape be equivalent with clicking
the relevant button.
<p>If <em>parent</em> is 0, then the message box becomes an application-global
modal dialog box. If <em>parent</em> is a widget, the message box becomes
modal relative to <em>parent.</em>
<p>See also <a href="#63edba">warning</a>() and <a href="#196e77">critical</a>().
<h3 class="fn">int<a name="66b7c8"></a>QMessageBox::information(<a href="qwidget.html">QWidget</a>*parent, const<a href="qstring.html">QString</a>&caption, const<a href="qstring.html">QString</a>&text, intbutton0, intbutton1=0, intbutton2=0) <code>[static]</code></h3>
<p>Opens an information message box with a caption, a text and up to three
buttons. Returns the identifier of the button that was clicked.
<p>If <em>parent</em> is 0, then the message box becomes an application-global
modal dialog box. If <em>parent</em> is a widget, the message box becomes
modal relative to <em>parent.</em>
<p>See also <a href="#63edba">warning</a>() and <a href="#196e77">critical</a>().
<p>Examples:
<a href="picture-picture-cpp.html#QMessageBox::information">picture/picture.cpp</a>
<h3 class="fn">void<a name="9b0ada"></a>QMessageBox::keyPressEvent(<a href="qkeyevent.html">QKeyEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#0a4482">QWidget.</a>
<h3 class="fn">void<a name="66e6d5"></a>QMessageBox::resizeEvent(<a href="qresizeevent.html">QResizeEvent</a>*) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#7d375f">QWidget.</a>
<h3 class="fn">void<a name="5e8cf5"></a>QMessageBox::setButtonText(intbutton, const<a href="qstring.html">QString</a>&text)</h3>
<p>Sets the text of the message box button <em>button</em> to <em>text.</em>
Setting the text of a button that is not in the message box is quietly
ignored.
<p>See also <a href="#9c8790">buttonText</a>().
<h3 class="fn">void<a name="c37e48"></a>QMessageBox::setIcon(<a href="qmessagebox.html#Icon">Icon</a>icon)</h3>
<p>Sets the icon of the message box to <em>icon,</em> which is a predefined icon:
<p><ul>
<li> <code>QMessageBox::NoIcon</code>
<li> <code>QMessageBox::Information</code>
<li> <code>QMessageBox::Warning</code>
<li> <code>QMessageBox::Critical</code>
</ul>
<p>The actual pixmap used for displaying the icon depends on the current
<a href="qwidget.html#027381">GUI style</a>. You can also set a custom pixmap icon
using the <a href="#db0550">setIconPixmap</a>() function.
<p>See also <a href="#59436e">icon</a>(), <a href="#db0550">setIconPixmap</a>() and <a href="#688e6a">iconPixmap</a>().
<h3 class="fn">void<a name="7b9199"></a>QMessageBox::setIcon(const<a href="qpixmap.html">QPixmap</a>&pix) <code>[virtual]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#504fc4">QWidget.</a>
<h3 class="fn">void<a name="db0550"></a>QMessageBox::setIconPixmap(const<a href="qpixmap.html">QPixmap</a>&pixmap)</h3>
<p>Sets the icon of the message box to a custom <em>pixmap.</em> Note that
it's often hard to draw one pixmap which looks appropriate in both
Motif and Windoes GUI styles. You may want to draw two.
<p>See also <a href="#688e6a">iconPixmap</a>() and <a href="#7b9199">setIcon</a>().
<h3 class="fn">void<a name="bc19a7"></a>QMessageBox::setText(const<a href="qstring.html">QString</a>&text)</h3>
<p>Sets the message box text to be displayed.
<p><em>text</em> will be interpreted either as a plain text or as a rich
text, depending on the text format setting; see <a href="#3c0699">setTextFormat</a>(). The
default setting is <code>AutoText,</code> i.e. the message box will try to
auto-detect the format of <em>text.</em>
<p>See also <a href="#163468">text</a>() and <a href="#3c0699">setTextFormat</a>().
<h3 class="fn">void<a name="3c0699"></a>QMessageBox::setTextFormat(<a href="qt.html#TextFormat">Qt::TextFormat</a>format)</h3>
<p>Sets the text format to <em>format.</em> See the <a href="qt.html#TextFormat">Qt::TextFormat</a> enum for
an explanation of the possible options.
<p>The default format is <code>AutoText.</code>
<p>See also <a href="#1c2c0b">textFormat</a>() and <a href="#bc19a7">setText</a>().
<h3 class="fn"><a href="qpixmap.html">QPixmap</a><a name="50866f"></a>QMessageBox::standardIcon(<a href="qmessagebox.html#Icon">Icon</a>icon, GUIStylestyle) <code>[static]</code></h3>
<p>Returns the pixmap used for a standard icon. This
allows the pixmaps to be used in more complex message boxes.
<h3 class="fn">void<a name="f7b808"></a>QMessageBox::styleChanged(<a href="qstyle.html">QStyle</a>&) <code>[protected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<h3 class="fn"><a href="qstring.html">QString</a><a name="163468"></a>QMessageBox::text()const</h3>
<p>Returns the message box text currently set, or a
<a href="qstring.html#e21796">null string</a>
if no text has been set.
<p>See also <a href="#bc19a7">setText</a>() and <a href="#1c2c0b">textFormat</a>().
<h3 class="fn">Qt::TextFormat<a name="1c2c0b"></a>QMessageBox::textFormat()const</h3>
<p>Returns the current text format.
<p>See also <a href="#3c0699">setTextFormat</a>().
<h3 class="fn">int<a name="63edba"></a>QMessageBox::warning(<a href="qwidget.html">QWidget</a>*parent, const<a href="qstring.html">QString</a>&caption, const<a href="qstring.html">QString</a>&text, const<a href="qstring.html">QString</a>&button0Text=QString::null, const<a href="qstring.html">QString</a>&button1Text=QString::null, const<a href="qstring.html">QString</a>&button2Text=QString::null, intdefaultButtonNumber=0, intescapeButtonNumber=-1) <code>[static]</code></h3>
<p>Displays a warning message box with a caption, a text and
1-3 buttons. Returns the number of the button that was clicked
(0, 1 or 2).
<p><em>button0Text</em> is the text of the first button and is optional. If
<em>button0Text</em> is not supplied, "OK" (translated) will be used.
<em>button1Text</em> is the text of the second button and is optional, and
<em>button2Text</em> is the text of the third button and is optional. <em>defaultbuttonNumber</em> (0-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). <em>escapeButtonNumber</em> is the
index of the Escape button; pressing Escape is the same as clicking
this button. It defaults to -1 (pressing Escape does nothing);
supply 0, 1 or 2 to make pressing Escape be equivalent with clicking
the relevant button.
<p>If <em>parent</em> is 0, then the message box becomes an application-global
modal dialog box. If <em>parent</em> is a widget, the message box becomes
modal relative to <em>parent.</em>
<p>See also <a href="#66b7c8">information</a>() and <a href="#196e77">critical</a>().
<p>Examples:
<a href="i18n-main-cpp.html#QMessageBox::warning">i18n/main.cpp</a>
<h3 class="fn">int<a name="e2f1b1"></a>QMessageBox::warning(<a href="qwidget.html">QWidget</a>*parent, const<a href="qstring.html">QString</a>&caption, const<a href="qstring.html">QString</a>&text, intbutton0, intbutton1, intbutton2=0) <code>[static]</code></h3>
<p>Opens a warning message box with a caption, a text and up to three
buttons. Returns the identifier of the button that was clicked.
<p>If <em>parent</em> is 0, then the message box becomes an application-global
modal dialog box. If <em>parent</em> is a widget, the message box becomes
modal relative to <em>parent.</em>
<p>See also <a href="#66b7c8">information</a>() and <a href="#196e77">critical</a>().
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|