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
  
     | 
    
      <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qmessagebox.cpp -->
  <title>Qt 4.8: QMessageBox Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtgui.html">QtGui</a></li>
<li>QMessageBox</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#the-property-based-api">The Property-based API</a></li>
<li class="level3"><a href="#rich-text-and-the-text-format-property">Rich Text and the Text Format Property</a></li>
<li class="level3"><a href="#severity-levels-and-the-icon-and-pixmap-properties">Severity Levels and the Icon and Pixmap Properties</a></li>
<li class="level2"><a href="#the-static-functions-api">The Static Functions API</a></li>
<li class="level2"><a href="#advanced-usage">Advanced Usage</a></li>
<li class="level2"><a href="#default-and-escape-keys">Default and Escape Keys</a></li>
</ul>
</div>
<h1 class="title">QMessageBox Class Reference</h1>
<!-- $$$QMessageBox-brief -->
<p>The QMessageBox class provides a modal dialog for informing the user or for asking the user a question and receiving an answer. <a href="#details">More...</a></p>
<!-- @@@QMessageBox -->
<pre class="cpp"> <span class="preprocessor">#include <QMessageBox></span></pre><p><b>Inherits: </b><a href="qdialog.html">QDialog</a>.</p>
<ul>
<li><a href="qmessagebox-members.html">List of all members, including inherited members</a></li>
<li><a href="qmessagebox-obsolete.html">Obsolete members</a></li>
<li><a href="qmessagebox-qt3.html">Qt 3 support members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#ButtonRole-enum">ButtonRole</a></b> { InvalidRole, AcceptRole, RejectRole, DestructiveRole, ..., ResetRole }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#Icon-enum">Icon</a></b> { NoIcon, Question, Information, Warning, Critical }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></b> { Ok, Open, Save, Cancel, ..., ButtonMask }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#StandardButton-enum">StandardButtons</a></b></td></tr>
</table>
<a name="properties"></a>
<h2>Properties</h2>
<table class="propsummary">
<tr><td class="topAlign"><ul>
<li class="fn"><b><a href="qmessagebox.html#detailedText-prop">detailedText</a></b> : QString</li>
<li class="fn"><b><a href="qmessagebox.html#icon-prop">icon</a></b> : Icon</li>
<li class="fn"><b><a href="qmessagebox.html#iconPixmap-prop">iconPixmap</a></b> : QPixmap</li>
<li class="fn"><b><a href="qmessagebox.html#informativeText-prop">informativeText</a></b> : QString</li>
</ul></td><td class="topAlign"><ul>
<li class="fn"><b><a href="qmessagebox.html#standardButtons-prop">standardButtons</a></b> : StandardButtons</li>
<li class="fn"><b><a href="qmessagebox.html#text-prop">text</a></b> : QString</li>
<li class="fn"><b><a href="qmessagebox.html#textFormat-prop">textFormat</a></b> : Qt::TextFormat</li>
</ul>
</td></tr>
</table>
<ul>
<li class="fn">2 properties inherited from <a href="qdialog.html#properties">QDialog</a></li>
<li class="fn">58 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#QMessageBox">QMessageBox</a></b> ( QWidget * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#QMessageBox-2">QMessageBox</a></b> ( Icon <i>icon</i>, const QString & <i>title</i>, const QString & <i>text</i>, StandardButtons <i>buttons</i> = NoButton, QWidget * <i>parent</i> = 0, Qt::WindowFlags <i>f</i> = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#dtor.QMessageBox">~QMessageBox</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#addButton">addButton</a></b> ( QAbstractButton * <i>button</i>, ButtonRole <i>role</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPushButton * </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#addButton-2">addButton</a></b> ( const QString & <i>text</i>, ButtonRole <i>role</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPushButton * </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#addButton-3">addButton</a></b> ( StandardButton <i>button</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAbstractButton * </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#button">button</a></b> ( StandardButton <i>which</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> ButtonRole </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#buttonRole">buttonRole</a></b> ( QAbstractButton * <i>button</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList<QAbstractButton *> </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#buttons">buttons</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAbstractButton * </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#clickedButton">clickedButton</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPushButton * </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#defaultButton">defaultButton</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#detailedText-prop">detailedText</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAbstractButton * </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#escapeButton">escapeButton</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Icon </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#icon-prop">icon</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPixmap </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#iconPixmap-prop">iconPixmap</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#informativeText-prop">informativeText</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#open">open</a></b> ( QObject * <i>receiver</i>, const char * <i>member</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#removeButton">removeButton</a></b> ( QAbstractButton * <i>button</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#setDefaultButton">setDefaultButton</a></b> ( QPushButton * <i>button</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#setDefaultButton-2">setDefaultButton</a></b> ( StandardButton <i>button</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#detailedText-prop">setDetailedText</a></b> ( const QString & <i>text</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#setEscapeButton">setEscapeButton</a></b> ( QAbstractButton * <i>button</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#setEscapeButton-2">setEscapeButton</a></b> ( StandardButton <i>button</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#icon-prop">setIcon</a></b> ( Icon )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#iconPixmap-prop">setIconPixmap</a></b> ( const QPixmap & <i>pixmap</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#informativeText-prop">setInformativeText</a></b> ( const QString & <i>text</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#standardButtons-prop">setStandardButtons</a></b> ( StandardButtons <i>buttons</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#text-prop">setText</a></b> ( const QString & <i>text</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#textFormat-prop">setTextFormat</a></b> ( Qt::TextFormat <i>format</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#setWindowModality">setWindowModality</a></b> ( Qt::WindowModality <i>windowModality</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#setWindowTitle">setWindowTitle</a></b> ( const QString & <i>title</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> StandardButton </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#standardButton">standardButton</a></b> ( QAbstractButton * <i>button</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> StandardButtons </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#standardButtons-prop">standardButtons</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#text-prop">text</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::TextFormat </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#textFormat-prop">textFormat</a></b> () const</td></tr>
</table>
<a name="reimplemented-public-functions"></a>
<h2>Reimplemented Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#setVisible">setVisible</a></b> ( bool <i>visible</i> )</td></tr>
</table>
<ul>
<li class="fn">8 public functions inherited from <a href="qdialog.html#public-functions">QDialog</a></li>
<li class="fn">221 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
<li class="fn">13 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
</ul>
<a name="public-slots"></a>
<h2>Public Slots</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#exec">exec</a></b> ()</td></tr>
</table>
<ul>
<li class="fn">5 public slots inherited from <a href="qdialog.html#public-slots">QDialog</a></li>
<li class="fn">19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h2>Signals</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#buttonClicked">buttonClicked</a></b> ( QAbstractButton * <i>button</i> )</td></tr>
</table>
<ul>
<li class="fn">3 signals inherited from <a href="qdialog.html#signals">QDialog</a></li>
<li class="fn">1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#about">about</a></b> ( QWidget * <i>parent</i>, const QString & <i>title</i>, const QString & <i>text</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#aboutQt">aboutQt</a></b> ( QWidget * <i>parent</i>, const QString & <i>title</i> = QString() )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> StandardButton </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#critical">critical</a></b> ( QWidget * <i>parent</i>, const QString & <i>title</i>, const QString & <i>text</i>, StandardButtons <i>buttons</i> = Ok, StandardButton <i>defaultButton</i> = NoButton )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> StandardButton </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#information">information</a></b> ( QWidget * <i>parent</i>, const QString & <i>title</i>, const QString & <i>text</i>, StandardButtons <i>buttons</i> = Ok, StandardButton <i>defaultButton</i> = NoButton )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> StandardButton </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#question">question</a></b> ( QWidget * <i>parent</i>, const QString & <i>title</i>, const QString & <i>text</i>, StandardButtons <i>buttons</i> = Ok, StandardButton <i>defaultButton</i> = NoButton )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> StandardButton </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#warning">warning</a></b> ( QWidget * <i>parent</i>, const QString & <i>title</i>, const QString & <i>text</i>, StandardButtons <i>buttons</i> = Ok, StandardButton <i>defaultButton</i> = NoButton )</td></tr>
</table>
<ul>
<li class="fn">4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="reimplemented-protected-functions"></a>
<h2>Reimplemented Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#changeEvent">changeEvent</a></b> ( QEvent * <i>ev</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#closeEvent">closeEvent</a></b> ( QCloseEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#event">event</a></b> ( QEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#keyPressEvent">keyPressEvent</a></b> ( QKeyEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#resizeEvent">resizeEvent</a></b> ( QResizeEvent * <i>event</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qmessagebox.html#showEvent">showEvent</a></b> ( QShowEvent * <i>e</i> )</td></tr>
</table>
<ul>
<li class="fn">7 protected functions inherited from <a href="qdialog.html#protected-functions">QDialog</a></li>
<li class="fn">37 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li class="fn">1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">7 protected functions inherited from <a href="qdialog.html#protected-functions">QDialog</a></li>
<li class="fn">37 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li class="fn">1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
<li class="fn">1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
</ul>
<a name="details"></a>
<!-- $$$QMessageBox-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QMessageBox class provides a modal dialog for informing the user or for asking the user a question and receiving an answer.</p>
<p>A message box displays a primary <a href="qmessagebox.html#text-prop">text</a> to alert the user to a situation, an <a href="qmessagebox.html#informativeText-prop">informative text</a> to further explain the alert or to ask the user a question, and an optional <a href="qmessagebox.html#detailedText-prop">detailed text</a> to provide even more data if the user requests it. A message box can also display an <a href="qmessagebox.html#icon-prop">icon</a> and <a href="qmessagebox.html#standardButtons-prop">standard buttons</a> for accepting a user response.</p>
<p>Two APIs for using QMessageBox are provided, the property-based API, and the static functions. Calling one of the static functions is the simpler approach, but it is less flexible than using the property-based API, and the result is less informative. Using the property-based API is recommended.</p>
<a name="the-property-based-api"></a>
<h3>The Property-based API</h3>
<p>To use the property-based API, construct an instance of QMessageBox, set the desired properties, and call <a href="qmessagebox.html#exec">exec</a>() to show the message. The simplest configuration is to set only the <a href="qmessagebox.html#text-prop">message text</a> property.</p>
<pre class="cpp"> <span class="type">QMessageBox</span> msgBox;
 msgBox<span class="operator">.</span><a href="qmessagebox.html#text-prop">setText</a>(<span class="string">"The document has been modified."</span>);
 msgBox<span class="operator">.</span><a href="qmessagebox.html#exec">exec</a>();</pre>
<p>The user must click the <b>OK</b> button to dismiss the message box. The rest of the GUI is blocked until the message box is dismissed.</p>
<p class="centerAlign"><img src="images/msgbox1.png" alt="" /></p><p>A better approach than just alerting the user to an event is to also ask the user what to do about it. Store the question in the <a href="qmessagebox.html#informativeText-prop">informative text</a> property, and set the <a href="qmessagebox.html#standardButtons-prop">standard buttons</a> property to the set of buttons you want as the set of user responses. The buttons are specified by combining values from <a href="qmessagebox.html#StandardButton-enum">StandardButtons</a> using the bitwise OR operator. The display order for the buttons is platform-dependent. For example, on Windows, <b>Save</b> is displayed to the left of <b>Cancel</b>, whereas on Mac OS, the order is reversed.</p>
<p>Mark one of your standard buttons to be your <a href="qmessagebox.html#defaultButton">default button</a>.</p>
<pre class="cpp"> <span class="type">QMessageBox</span> msgBox;
 msgBox<span class="operator">.</span><a href="qmessagebox.html#text-prop">setText</a>(<span class="string">"The document has been modified."</span>);
 msgBox<span class="operator">.</span><a href="qmessagebox.html#informativeText-prop">setInformativeText</a>(<span class="string">"Do you want to save your changes?"</span>);
 msgBox<span class="operator">.</span><a href="qmessagebox.html#standardButtons-prop">setStandardButtons</a>(<span class="type">QMessageBox</span><span class="operator">::</span>Save <span class="operator">|</span> <span class="type">QMessageBox</span><span class="operator">::</span>Discard <span class="operator">|</span> <span class="type">QMessageBox</span><span class="operator">::</span>Cancel);
 msgBox<span class="operator">.</span><a href="qmessagebox.html#setDefaultButton">setDefaultButton</a>(<span class="type">QMessageBox</span><span class="operator">::</span>Save);
 <span class="type">int</span> ret <span class="operator">=</span> msgBox<span class="operator">.</span><a href="qmessagebox.html#exec">exec</a>();</pre>
<p>This is the approach recommended in the <a href="http://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/AppleHIGuidelines/Windows/Windows.html#//apple_ref/doc/uid/20000961-BABCAJID">Mac OS X Guidelines</a>. Similar guidelines apply for the other platforms, but note the different ways the <a href="qmessagebox.html#informativeText-prop">informative text</a> is handled for different platforms.</p>
<p class="centerAlign"><img src="images/msgbox2.png" alt="" /></p><p>The <a href="qmessagebox.html#exec">exec</a>() slot returns the <a href="qmessagebox.html#StandardButton-enum">StandardButtons</a> value of the button that was clicked.</p>
<pre class="cpp"> <span class="keyword">switch</span> (ret) {
   <span class="keyword">case</span> <span class="type">QMessageBox</span><span class="operator">::</span>Save:
       <span class="comment">// Save was clicked</span>
       <span class="keyword">break</span>;
   <span class="keyword">case</span> <span class="type">QMessageBox</span><span class="operator">::</span>Discard:
       <span class="comment">// Don't Save was clicked</span>
       <span class="keyword">break</span>;
   <span class="keyword">case</span> <span class="type">QMessageBox</span><span class="operator">::</span>Cancel:
       <span class="comment">// Cancel was clicked</span>
       <span class="keyword">break</span>;
   <span class="keyword">default</span>:
       <span class="comment">// should never be reached</span>
       <span class="keyword">break</span>;
 }</pre>
<p>To give the user more information to help him answer the question, set the <a href="qmessagebox.html#detailedText-prop">detailed text</a> property. If the <a href="qmessagebox.html#detailedText-prop">detailed text</a> property is set, the <b>Show Details...</b> button will be shown.</p>
<p class="centerAlign"><img src="images/msgbox3.png" alt="" /></p><p>Clicking the <b>Show Details...</b> button displays the detailed text.</p>
<p class="centerAlign"><img src="images/msgbox4.png" alt="" /></p><a name="rich-text-and-the-text-format-property"></a>
<h4>Rich Text and the Text Format Property</h4>
<p>The <a href="qmessagebox.html#detailedText-prop">detailed text</a> property is always interpreted as plain text. The <a href="qmessagebox.html#text-prop">main text</a> and <a href="qmessagebox.html#informativeText-prop">informative text</a> properties can be either plain text or rich text. These strings are interpreted according to the setting of the <a href="qmessagebox.html#textFormat-prop">text format</a> property. The default setting is <a href="qt.html#TextFormat-enum">auto-text</a>.</p>
<p>Note that for some plain text strings containing XML meta-characters, the auto-text <a href="qt.html#mightBeRichText">rich text detection test</a> may fail causing your plain text string to be interpreted incorrectly as rich text. In these rare cases, use <a href="qt.html#convertFromPlainText">Qt::convertFromPlainText</a>() to convert your plain text string to a visually equivalent rich text string, or set the <a href="qmessagebox.html#textFormat-prop">text format</a> property explicitly with <a href="qmessagebox.html#textFormat-prop">setTextFormat</a>().</p>
<a name="severity-levels-and-the-icon-and-pixmap-properties"></a>
<h4>Severity Levels and the Icon and Pixmap Properties</h4>
<p>QMessageBox supports four predefined message severity levels, or message types, which really only differ in the predefined icon they each show. Specify one of the four predefined message types by setting the <a href="qmessagebox.html#icon-prop">icon</a> property to one of the <a href="qmessagebox.html#Icon-enum">predefined icons</a>. The following rules are guidelines:</p>
<table class="generic">
<tr valign="top" class="odd"><td ><p class="centerAlign"><img src="images/qmessagebox-quest.png" alt="" /></p></td><td ><a href="qmessagebox.html#Icon-enum">Question</a></td><td >For asking a question during normal operations.</td></tr>
<tr valign="top" class="even"><td ><p class="centerAlign"><img src="images/qmessagebox-info.png" alt="" /></p></td><td ><a href="qmessagebox.html#Icon-enum">Information</a></td><td >For reporting information about normal operations.</td></tr>
<tr valign="top" class="odd"><td ><p class="centerAlign"><img src="images/qmessagebox-warn.png" alt="" /></p></td><td ><a href="qmessagebox.html#Icon-enum">Warning</a></td><td >For reporting non-critical errors.</td></tr>
<tr valign="top" class="even"><td ><p class="centerAlign"><img src="images/qmessagebox-crit.png" alt="" /></p></td><td ><a href="qmessagebox.html#Icon-enum">Critical</a></td><td >For reporting critical errors.</td></tr>
</table>
<p><a href="qmessagebox.html#Icon-enum">Predefined icons</a> are not defined by QMessageBox, but provided by the style. The default value is <a href="qmessagebox.html#Icon-enum">No Icon</a>. The message boxes are otherwise the same for all cases. When using a standard icon, use the one recommended in the table, or use the one recommended by the style guidelines for your platform. If none of the standard icons is right for your message box, you can use a custom icon by setting the <a href="qmessagebox.html#iconPixmap-prop">icon pixmap</a> property instead of setting the <a href="qmessagebox.html#icon-prop">icon</a> property.</p>
<p>In summary, to set an icon, use <i>either</i> <a href="qmessagebox.html#icon-prop">setIcon</a>() for one of the standard icons, <i>or</i> <a href="qmessagebox.html#iconPixmap-prop">setIconPixmap</a>() for a custom icon.</p>
<a name="the-static-functions-api"></a>
<h3>The Static Functions API</h3>
<p>Building message boxes with the static functions API, although convenient, is less flexible than using the property-based API, because the static function signatures lack parameters for setting the <a href="qmessagebox.html#informativeText-prop">informative text</a> and <a href="qmessagebox.html#detailedText-prop">detailed text</a> properties. One work-around for this has been to use the <tt>title</tt> parameter as the message box main text and the <tt>text</tt> parameter as the message box informative text. Because this has the obvious drawback of making a less readable message box, platform guidelines do not recommend it. The <i>Microsoft Windows User Interface Guidelines</i> recommend using the <a href="qcoreapplication.html#applicationName-prop">application name</a> as the <a href="qmessagebox.html#setWindowTitle">window's title</a>, which means that if you have an informative text in addition to your main text, you must concatenate it to the <tt>text</tt> parameter.</p>
<p>Note that the static function signatures have changed with respect to their button parameters, which are now used to set the <a href="qmessagebox.html#standardButtons-prop">standard buttons</a> and the <a href="qmessagebox.html#defaultButton">default button</a>.</p>
<p>Static functions are available for creating <a href="qmessagebox.html#information">information</a>(), <a href="qmessagebox.html#question">question</a>(), <a href="qmessagebox.html#warning">warning</a>(), and <a href="qmessagebox.html#critical">critical</a>() message boxes.</p>
<pre class="cpp"> <span class="type">int</span> ret <span class="operator">=</span> <span class="type">QMessageBox</span><span class="operator">::</span><a href="qmessagebox.html#warning">warning</a>(<span class="keyword">this</span><span class="operator">,</span> tr(<span class="string">"My Application"</span>)<span class="operator">,</span>
                                tr(<span class="string">"The document has been modified.\n"</span>
                                   <span class="string">"Do you want to save your changes?"</span>)<span class="operator">,</span>
                                <span class="type">QMessageBox</span><span class="operator">::</span>Save <span class="operator">|</span> <span class="type">QMessageBox</span><span class="operator">::</span>Discard
                                <span class="operator">|</span> <span class="type">QMessageBox</span><span class="operator">::</span>Cancel<span class="operator">,</span>
                                <span class="type">QMessageBox</span><span class="operator">::</span>Save);</pre>
<p>The <a href="dialogs-standarddialogs.html">Standard Dialogs</a> example shows how to use QMessageBox and the other built-in Qt dialogs.</p>
<a name="advanced-usage"></a>
<h3>Advanced Usage</h3>
<p>If the <a href="qmessagebox.html#StandardButton-enum">standard buttons</a> are not flexible enough for your message box, you can use the <a href="qmessagebox.html#addButton">addButton</a>() overload that takes a text and a ButtonRoleto to add custom buttons. The <a href="qmessagebox.html#ButtonRole-enum">ButtonRole</a> is used by QMessageBox to determine the ordering of the buttons on screen (which varies according to the platform). You can test the value of <a href="qmessagebox.html#clickedButton">clickedButton</a>() after calling <a href="qmessagebox.html#exec">exec</a>(). For example,</p>
<pre class="cpp"> <span class="type">QMessageBox</span> msgBox;
 <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>connectButton <span class="operator">=</span> msgBox<span class="operator">.</span><a href="qmessagebox.html#addButton">addButton</a>(tr(<span class="string">"Connect"</span>)<span class="operator">,</span> <span class="type">QMessageBox</span><span class="operator">::</span>ActionRole);
 <span class="type"><a href="qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>abortButton <span class="operator">=</span> msgBox<span class="operator">.</span><a href="qmessagebox.html#addButton">addButton</a>(<span class="type">QMessageBox</span><span class="operator">::</span>Abort);
 msgBox<span class="operator">.</span><a href="qmessagebox.html#exec">exec</a>();
 <span class="keyword">if</span> (msgBox<span class="operator">.</span>clickedButton() <span class="operator">=</span><span class="operator">=</span> connectButton) {
     <span class="comment">// connect</span>
 } <span class="keyword">else</span> <span class="keyword">if</span> (msgBox<span class="operator">.</span>clickedButton() <span class="operator">=</span><span class="operator">=</span> abortButton) {
     <span class="comment">// abort</span>
 }</pre>
<a name="default-and-escape-keys"></a>
<h3>Default and Escape Keys</h3>
<p>The default button (i.e., the button activated when <b>Enter</b> is pressed) can be specified using <a href="qmessagebox.html#setDefaultButton">setDefaultButton</a>(). If a default button is not specified, QMessageBox tries to find one based on the <a href="qmessagebox.html#ButtonRole-enum">button roles</a> of the buttons used in the message box.</p>
<p>The escape button (the button activated when <b>Esc</b> is pressed) can be specified using <a href="qmessagebox.html#setEscapeButton">setEscapeButton</a>(). If an escape button is not specified, QMessageBox tries to find one using these rules:</p>
<ol class="1">
<li>If there is only one button, it is the button activated when <b>Esc</b> is pressed.</li>
<li>If there is a <a href="qmessagebox.html#StandardButton-enum">Cancel</a> button, it is the button activated when <b>Esc</b> is pressed.</li>
<li>If there is exactly one button having either <a href="qmessagebox.html#ButtonRole-enum">the Reject role</a> or the <a href="qmessagebox.html#ButtonRole-enum">the No role</a>, it is the button activated when <b>Esc</b> is pressed.</li>
</ol>
<p>When an escape button can't be determined using these rules, pressing <b>Esc</b> has no effect.</p>
</div>
<p><b>See also </b><a href="qdialogbuttonbox.html">QDialogButtonBox</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Message Box</a>, <a href="dialogs-standarddialogs.html">Standard Dialogs Example</a>, and <a href="mainwindows-application.html">Application Example</a>.</p>
<!-- @@@QMessageBox -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ButtonRole$$$InvalidRole$$$AcceptRole$$$RejectRole$$$DestructiveRole$$$ActionRole$$$HelpRole$$$YesRole$$$NoRole$$$ResetRole$$$ApplyRole$$$NRoles -->
<h3 class="fn"><a name="ButtonRole-enum"></a>enum QMessageBox::<span class="name">ButtonRole</span></h3>
<p>This enum describes the roles that can be used to describe buttons in the button box. Combinations of these roles are as flags used to describe different aspects of their behavior.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QMessageBox::InvalidRole</tt></td><td class="topAlign"><tt>-1</tt></td><td class="topAlign">The button is invalid.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::AcceptRole</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">Clicking the button causes the dialog to be accepted (e.g. OK).</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::RejectRole</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">Clicking the button causes the dialog to be rejected (e.g. Cancel).</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::DestructiveRole</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">Clicking the button causes a destructive change (e.g. for Discarding Changes) and closes the dialog.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::ActionRole</tt></td><td class="topAlign"><tt>3</tt></td><td class="topAlign">Clicking the button causes changes to the elements within the dialog.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::HelpRole</tt></td><td class="topAlign"><tt>4</tt></td><td class="topAlign">The button can be clicked to request help.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::YesRole</tt></td><td class="topAlign"><tt>5</tt></td><td class="topAlign">The button is a "Yes"-like button.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::NoRole</tt></td><td class="topAlign"><tt>6</tt></td><td class="topAlign">The button is a "No"-like button.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::ApplyRole</tt></td><td class="topAlign"><tt>8</tt></td><td class="topAlign">The button applies current changes.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::ResetRole</tt></td><td class="topAlign"><tt>7</tt></td><td class="topAlign">The button resets the dialog's fields to default values.</td></tr>
</table>
<p><b>See also </b><a href="qmessagebox.html#StandardButton-enum">StandardButton</a>.</p>
<!-- @@@ButtonRole -->
<!-- $$$Icon$$$NoIcon$$$Information$$$Warning$$$Critical$$$Question -->
<h3 class="fn"><a name="Icon-enum"></a>enum QMessageBox::<span class="name">Icon</span></h3>
<p>This enum has the following values:</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QMessageBox::NoIcon</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">the message box does not have any icon.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Question</tt></td><td class="topAlign"><tt>4</tt></td><td class="topAlign">an icon indicating that the message is asking a question.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Information</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">an icon indicating that the message is nothing out of the ordinary.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Warning</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">an icon indicating that the message is a warning, but can be dealt with.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Critical</tt></td><td class="topAlign"><tt>3</tt></td><td class="topAlign">an icon indicating that the message represents a critical problem.</td></tr>
</table>
<!-- @@@Icon -->
<!-- $$$StandardButton$$$NoButton$$$Ok$$$Save$$$SaveAll$$$Open$$$Yes$$$YesToAll$$$No$$$NoToAll$$$Abort$$$Retry$$$Ignore$$$Close$$$Cancel$$$Discard$$$Help$$$Apply$$$Reset$$$RestoreDefaults$$$FirstButton$$$LastButton$$$YesAll$$$NoAll$$$Default$$$Escape$$$FlagMask$$$ButtonMask -->
<h3 class="flags"><a name="StandardButton-enum"></a>enum QMessageBox::<span class="name">StandardButton</span><br/>flags QMessageBox::<span class="name">StandardButtons</span></h3>
<p>These enums describe flags for standard buttons. Each button has a defined <a href="qmessagebox.html#ButtonRole-enum">ButtonRole</a>.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QMessageBox::Ok</tt></td><td class="topAlign"><tt>0x00000400</tt></td><td class="topAlign">An "OK" button defined with the <a href="qmessagebox.html#ButtonRole-enum">AcceptRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Open</tt></td><td class="topAlign"><tt>0x00002000</tt></td><td class="topAlign">A "Open" button defined with the <a href="qmessagebox.html#ButtonRole-enum">AcceptRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Save</tt></td><td class="topAlign"><tt>0x00000800</tt></td><td class="topAlign">A "Save" button defined with the <a href="qmessagebox.html#ButtonRole-enum">AcceptRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Cancel</tt></td><td class="topAlign"><tt>0x00400000</tt></td><td class="topAlign">A "Cancel" button defined with the <a href="qmessagebox.html#ButtonRole-enum">RejectRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Close</tt></td><td class="topAlign"><tt>0x00200000</tt></td><td class="topAlign">A "Close" button defined with the <a href="qmessagebox.html#ButtonRole-enum">RejectRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Discard</tt></td><td class="topAlign"><tt>0x00800000</tt></td><td class="topAlign">A "Discard" or "Don't Save" button, depending on the platform, defined with the <a href="qmessagebox.html#ButtonRole-enum">DestructiveRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Apply</tt></td><td class="topAlign"><tt>0x02000000</tt></td><td class="topAlign">An "Apply" button defined with the <a href="qmessagebox.html#ButtonRole-enum">ApplyRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Reset</tt></td><td class="topAlign"><tt>0x04000000</tt></td><td class="topAlign">A "Reset" button defined with the <a href="qmessagebox.html#ButtonRole-enum">ResetRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::RestoreDefaults</tt></td><td class="topAlign"><tt>0x08000000</tt></td><td class="topAlign">A "Restore Defaults" button defined with the <a href="qmessagebox.html#ButtonRole-enum">ResetRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Help</tt></td><td class="topAlign"><tt>0x01000000</tt></td><td class="topAlign">A "Help" button defined with the <a href="qmessagebox.html#ButtonRole-enum">HelpRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::SaveAll</tt></td><td class="topAlign"><tt>0x00001000</tt></td><td class="topAlign">A "Save All" button defined with the <a href="qmessagebox.html#ButtonRole-enum">AcceptRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Yes</tt></td><td class="topAlign"><tt>0x00004000</tt></td><td class="topAlign">A "Yes" button defined with the <a href="qmessagebox.html#ButtonRole-enum">YesRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::YesToAll</tt></td><td class="topAlign"><tt>0x00008000</tt></td><td class="topAlign">A "Yes to All" button defined with the <a href="qmessagebox.html#ButtonRole-enum">YesRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::No</tt></td><td class="topAlign"><tt>0x00010000</tt></td><td class="topAlign">A "No" button defined with the <a href="qmessagebox.html#ButtonRole-enum">NoRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::NoToAll</tt></td><td class="topAlign"><tt>0x00020000</tt></td><td class="topAlign">A "No to All" button defined with the <a href="qmessagebox.html#ButtonRole-enum">NoRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Abort</tt></td><td class="topAlign"><tt>0x00040000</tt></td><td class="topAlign">An "Abort" button defined with the <a href="qmessagebox.html#ButtonRole-enum">RejectRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Retry</tt></td><td class="topAlign"><tt>0x00080000</tt></td><td class="topAlign">A "Retry" button defined with the <a href="qmessagebox.html#ButtonRole-enum">AcceptRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Ignore</tt></td><td class="topAlign"><tt>0x00100000</tt></td><td class="topAlign">An "Ignore" button defined with the <a href="qmessagebox.html#ButtonRole-enum">AcceptRole</a>.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::NoButton</tt></td><td class="topAlign"><tt>0x00000000</tt></td><td class="topAlign">An invalid button.</td></tr>
</table>
<p>The following values are obsolete:</p>
<table class="valuelist"><tr valign="top" class="even"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QMessageBox::YesAll</tt></td><td class="topAlign"><tt>YesToAll</tt></td><td class="topAlign">Use YesToAll instead.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::NoAll</tt></td><td class="topAlign"><tt>NoToAll</tt></td><td class="topAlign">Use NoToAll instead.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Default</tt></td><td class="topAlign"><tt>0x00000100</tt></td><td class="topAlign">Use the <tt>defaultButton</tt> argument of <a href="qmessagebox.html#information">information</a>(), <a href="qmessagebox.html#warning">warning</a>(), etc. instead, or call <a href="qmessagebox.html#setDefaultButton">setDefaultButton</a>().</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::Escape</tt></td><td class="topAlign"><tt>0x00000200</tt></td><td class="topAlign">Call <a href="qmessagebox.html#setEscapeButton">setEscapeButton</a>() instead.</td></tr>
<tr><td class="topAlign"><tt>QMessageBox::FlagMask</tt></td><td class="topAlign"><tt>0x00000300</tt></td><td class="topAlign"> </td></tr>
<tr><td class="topAlign"><tt>QMessageBox::ButtonMask</tt></td><td class="topAlign"><tt>~FlagMask</tt></td><td class="topAlign"> </td></tr>
</table>
<p>This enum was introduced or modified in Qt 4.2.</p>
<p>The StandardButtons type is a typedef for <a href="qflags.html">QFlags</a><StandardButton>. It stores an OR combination of StandardButton values.</p>
<p><b>See also </b><a href="qmessagebox.html#ButtonRole-enum">ButtonRole</a> and <a href="qmessagebox.html#standardButtons-prop">standardButtons</a>.</p>
<!-- @@@StandardButton -->
</div>
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$detailedText-prop$$$detailedText$$$setDetailedTextconstQString& -->
<h3 class="fn"><a name="detailedText-prop"></a><span class="name">detailedText</span> : <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the text to be displayed in the details area.</p>
<p>The text will be interpreted as a plain text.</p>
<p>By default, this property contains an empty string.</p>
<p>This property was introduced in Qt 4.2.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>detailedText</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setDetailedText</b></span> ( const QString & <i>text</i> )</td></tr>
</table>
<p><b>See also </b><a href="qmessagebox.html#text-prop">QMessageBox::text</a> and <a href="qmessagebox.html#informativeText-prop">QMessageBox::informativeText</a>.</p>
<!-- @@@detailedText -->
<!-- $$$icon-prop$$$icon$$$setIconIcon -->
<h3 class="fn"><a name="icon-prop"></a><span class="name">icon</span> : <span class="type"><a href="qmessagebox.html#Icon-enum">Icon</a></span></h3>
<p>This property holds the message box's icon.</p>
<p>The icon of the message box can be specified with one of the values:</p>
<ul>
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::NoIcon</a></li>
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Question</a></li>
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Information</a></li>
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Warning</a></li>
<li><a href="qmessagebox.html#Icon-enum">QMessageBox::Critical</a></li>
</ul>
<p>The default is <a href="qmessagebox.html#Icon-enum">QMessageBox::NoIcon</a>.</p>
<p>The pixmap used to display the actual icon depends on the current <a href="qwidget.html#style">GUI style</a>. You can also set a custom pixmap for the icon by setting the <a href="qmessagebox.html#iconPixmap-prop">icon pixmap</a> property.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> Icon </td><td class="memItemRight bottomAlign"><span class="name"><b>icon</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setIcon</b></span> ( Icon )</td></tr>
</table>
<p><b>See also </b><a href="qmessagebox.html#iconPixmap-prop">iconPixmap</a>.</p>
<!-- @@@icon -->
<!-- $$$iconPixmap-prop$$$iconPixmap$$$setIconPixmapconstQPixmap& -->
<h3 class="fn"><a name="iconPixmap-prop"></a><span class="name">iconPixmap</span> : <span class="type"><a href="qpixmap.html">QPixmap</a></span></h3>
<p>This property holds the current icon.</p>
<p>The icon currently used by the message box. Note that it's often hard to draw one pixmap that looks appropriate in all GUI styles; you may want to supply a different pixmap for each platform.</p>
<p>By default, this property is undefined.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QPixmap </td><td class="memItemRight bottomAlign"><span class="name"><b>iconPixmap</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setIconPixmap</b></span> ( const QPixmap & <i>pixmap</i> )</td></tr>
</table>
<p><b>See also </b><a href="qmessagebox.html#icon-prop">icon</a>.</p>
<!-- @@@iconPixmap -->
<!-- $$$informativeText-prop$$$informativeText$$$setInformativeTextconstQString& -->
<h3 class="fn"><a name="informativeText-prop"></a><span class="name">informativeText</span> : <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the informative text that provides a fuller description for the message.</p>
<p>Infromative text can be used to expand upon the <a href="qmessagebox.html#text-prop">text</a>() to give more information to the user. On the Mac, this text appears in small system font below the <a href="qmessagebox.html#text-prop">text</a>(). On other platforms, it is simply appended to the existing text.</p>
<p>By default, this property contains an empty string.</p>
<p>This property was introduced in Qt 4.2.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>informativeText</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setInformativeText</b></span> ( const QString & <i>text</i> )</td></tr>
</table>
<p><b>See also </b><a href="qmessagebox.html#text-prop">QMessageBox::text</a> and <a href="qmessagebox.html#detailedText-prop">QMessageBox::detailedText</a>.</p>
<!-- @@@informativeText -->
<!-- $$$standardButtons-prop$$$standardButtons$$$setStandardButtonsStandardButtons -->
<h3 class="fn"><a name="standardButtons-prop"></a><span class="name">standardButtons</span> : <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButtons</a></span></h3>
<p>This property holds collection of standard buttons in the message box.</p>
<p>This property controls which standard buttons are used by the message box.</p>
<p>By default, this property contains no standard buttons.</p>
<p>This property was introduced in Qt 4.2.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> StandardButtons </td><td class="memItemRight bottomAlign"><span class="name"><b>standardButtons</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setStandardButtons</b></span> ( StandardButtons <i>buttons</i> )</td></tr>
</table>
<p><b>See also </b><a href="qmessagebox.html#addButton">addButton</a>().</p>
<!-- @@@standardButtons -->
<!-- $$$text-prop$$$text$$$setTextconstQString& -->
<h3 class="fn"><a name="text-prop"></a><span class="name">text</span> : <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the message box text to be displayed.</p>
<p>The text will be interpreted either as a plain text or as rich text, depending on the text format setting (<a href="qmessagebox.html#textFormat-prop">QMessageBox::textFormat</a>). The default setting is <a href="qt.html#TextFormat-enum">Qt::AutoText</a>, i.e., the message box will try to auto-detect the format of the text.</p>
<p>The default value of this property is an empty string.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>text</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setText</b></span> ( const QString & <i>text</i> )</td></tr>
</table>
<p><b>See also </b><a href="qmessagebox.html#textFormat-prop">textFormat</a>, <a href="qmessagebox.html#informativeText-prop">QMessageBox::informativeText</a>, and <a href="qmessagebox.html#detailedText-prop">QMessageBox::detailedText</a>.</p>
<!-- @@@text -->
<!-- $$$textFormat-prop$$$textFormat$$$setTextFormatQt::TextFormat -->
<h3 class="fn"><a name="textFormat-prop"></a><span class="name">textFormat</span> : <span class="type"><a href="qt.html#TextFormat-enum">Qt::TextFormat</a></span></h3>
<p>This property holds the format of the text displayed by the message box.</p>
<p>The current text format used by the message box. See the <a href="qt.html#TextFormat-enum">Qt::TextFormat</a> enum for an explanation of the possible options.</p>
<p>The default format is <a href="qt.html#TextFormat-enum">Qt::AutoText</a>.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> Qt::TextFormat </td><td class="memItemRight bottomAlign"><span class="name"><b>textFormat</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTextFormat</b></span> ( Qt::TextFormat <i>format</i> )</td></tr>
</table>
<p><b>See also </b><a href="qmessagebox.html#text-prop">setText</a>().</p>
<!-- @@@textFormat -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QMessageBox[overload1]$$$QMessageBoxQWidget* -->
<h3 class="fn"><a name="QMessageBox"></a>QMessageBox::<span class="name">QMessageBox</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i> = 0 )</h3>
<p>Constructs a message box with no text and no buttons. <i>parent</i> is passed to the <a href="qdialog.html">QDialog</a> constructor.</p>
<p>On Mac OS X, if you want your message box to appear as a <a href="qt.html#WindowType-enum">Qt::Sheet</a> of its <i>parent</i>, set the message box's <a href="qmessagebox.html#setWindowModality">window modality</a> to <a href="qt.html#WindowModality-enum">Qt::WindowModal</a> or use <a href="qmessagebox.html#open">open</a>(). Otherwise, the message box will be a standard dialog.</p>
<!-- @@@QMessageBox -->
<!-- $$$QMessageBox$$$QMessageBoxIconconstQString&constQString&StandardButtonsQWidget*Qt::WindowFlags -->
<h3 class="fn"><a name="QMessageBox-2"></a>QMessageBox::<span class="name">QMessageBox</span> ( <span class="type"><a href="qmessagebox.html#Icon-enum">Icon</a></span> <i>icon</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>title</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButtons</a></span> <i>buttons</i> = NoButton, <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i> = 0, <span class="type"><a href="qt.html#WindowType-enum">Qt::WindowFlags</a></span> <i>f</i> = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint )</h3>
<p>Constructs a message box with the given <i>icon</i>, <i>title</i>, <i>text</i>, and standard <i>buttons</i>. Standard or custom buttons can be added at any time using <a href="qmessagebox.html#addButton">addButton</a>(). The <i>parent</i> and <i>f</i> arguments are passed to the <a href="qdialog.html">QDialog</a> constructor.</p>
<p>The message box is an <a href="qt.html#WindowModality-enum">application modal</a> dialog box.</p>
<p>On Mac OS X, if <i>parent</i> is not 0 and you want your message box to appear as a <a href="qt.html#WindowType-enum">Qt::Sheet</a> of that parent, set the message box's <a href="qmessagebox.html#setWindowModality">window modality</a> to <a href="qt.html#WindowModality-enum">Qt::WindowModal</a> (default). Otherwise, the message box will be a standard dialog.</p>
<p><b>See also </b><a href="qmessagebox.html#setWindowTitle">setWindowTitle</a>(), <a href="qmessagebox.html#text-prop">setText</a>(), <a href="qmessagebox.html#icon-prop">setIcon</a>(), and <a href="qmessagebox.html#standardButtons-prop">setStandardButtons</a>().</p>
<!-- @@@QMessageBox -->
<!-- $$$~QMessageBox[overload1]$$$~QMessageBox -->
<h3 class="fn"><a name="dtor.QMessageBox"></a>QMessageBox::<span class="name">~QMessageBox</span> ()</h3>
<p>Destroys the message box.</p>
<!-- @@@~QMessageBox -->
<!-- $$$about[overload1]$$$aboutQWidget*constQString&constQString& -->
<h3 class="fn"><a name="about"></a><span class="type">void</span> QMessageBox::<span class="name">about</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>title</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i> )<tt> [static]</tt></h3>
<p>Displays a simple about box with title <i>title</i> and text <i>text</i>. The about box's parent is <i>parent</i>.</p>
<p>about() looks for a suitable icon in four locations:</p>
<ol class="1">
<li>It prefers <a href="qwidget.html#windowIcon-prop">parent->icon()</a> if that exists.</li>
<li>If not, it tries the top-level widget containing <i>parent</i>.</li>
<li>If that fails, it tries the <a href="qapplication.html#activeWindow">active window.</a></li>
<li>As a last resort it uses the Information icon.</li>
</ol>
<p>The about box has a single button labelled "OK". On Mac OS X, the about box is popped up as a modeless window; on other platforms, it is currently application modal.</p>
<p><b>See also </b><a href="qwidget.html#windowIcon-prop">QWidget::windowIcon</a>() and <a href="qapplication.html#activeWindow">QApplication::activeWindow</a>().</p>
<!-- @@@about -->
<!-- $$$aboutQt[overload1]$$$aboutQtQWidget*constQString& -->
<h3 class="fn"><a name="aboutQt"></a><span class="type">void</span> QMessageBox::<span class="name">aboutQt</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>title</i> = QString() )<tt> [static]</tt></h3>
<p>Displays a simple message box about Qt, with the given <i>title</i> and centered over <i>parent</i> (if <i>parent</i> is not 0). The message includes the version number of Qt being used by the application.</p>
<p>This is useful for inclusion in the <b>Help</b> menu of an application, as shown in the <a href="mainwindows-menus.html">Menus</a> example.</p>
<p><a href="qapplication.html">QApplication</a> provides this functionality as a slot.</p>
<p>On Mac OS X, the about box is popped up as a modeless window; on other platforms, it is currently application modal.</p>
<p><b>See also </b><a href="qapplication.html#aboutQt">QApplication::aboutQt</a>().</p>
<!-- @@@aboutQt -->
<!-- $$$addButton[overload1]$$$addButtonQAbstractButton*ButtonRole -->
<h3 class="fn"><a name="addButton"></a><span class="type">void</span> QMessageBox::<span class="name">addButton</span> ( <span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> * <i>button</i>, <span class="type"><a href="qmessagebox.html#ButtonRole-enum">ButtonRole</a></span> <i>role</i> )</h3>
<p>Adds the given <i>button</i> to the message box with the specified <i>role</i>.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#removeButton">removeButton</a>(), <a href="qmessagebox.html#button">button</a>(), and <a href="qmessagebox.html#standardButtons-prop">setStandardButtons</a>().</p>
<!-- @@@addButton -->
<!-- $$$addButton$$$addButtonconstQString&ButtonRole -->
<h3 class="fn"><a name="addButton-2"></a><span class="type"><a href="qpushbutton.html">QPushButton</a></span> * QMessageBox::<span class="name">addButton</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type"><a href="qmessagebox.html#ButtonRole-enum">ButtonRole</a></span> <i>role</i> )</h3>
<p>This is an overloaded function.</p>
<p>Creates a button with the given <i>text</i>, adds it to the message box for the specified <i>role</i>, and returns it.</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@addButton -->
<!-- $$$addButton$$$addButtonStandardButton -->
<h3 class="fn"><a name="addButton-3"></a><span class="type"><a href="qpushbutton.html">QPushButton</a></span> * QMessageBox::<span class="name">addButton</span> ( <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> <i>button</i> )</h3>
<p>This is an overloaded function.</p>
<p>Adds a standard <i>button</i> to the message box if it is valid to do so, and returns the push button.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#standardButtons-prop">setStandardButtons</a>().</p>
<!-- @@@addButton -->
<!-- $$$button[overload1]$$$buttonStandardButton -->
<h3 class="fn"><a name="button"></a><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> * QMessageBox::<span class="name">button</span> ( <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> <i>which</i> ) const</h3>
<p>Returns a pointer corresponding to the standard button <i>which</i>, or 0 if the standard button doesn't exist in this message box.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#standardButtons-prop">standardButtons</a> and <a href="qmessagebox.html#standardButton">standardButton</a>().</p>
<!-- @@@button -->
<!-- $$$buttonClicked[overload1]$$$buttonClickedQAbstractButton* -->
<h3 class="fn"><a name="buttonClicked"></a><span class="type">void</span> QMessageBox::<span class="name">buttonClicked</span> ( <span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> * <i>button</i> )<tt> [signal]</tt></h3>
<p>This signal is emitted whenever a button is clicked inside the <a href="qmessagebox.html">QMessageBox</a>. The button that was clicked in returned in <i>button</i>.</p>
<!-- @@@buttonClicked -->
<!-- $$$buttonRole[overload1]$$$buttonRoleQAbstractButton* -->
<h3 class="fn"><a name="buttonRole"></a><span class="type"><a href="qmessagebox.html#ButtonRole-enum">ButtonRole</a></span> QMessageBox::<span class="name">buttonRole</span> ( <span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> * <i>button</i> ) const</h3>
<p>Returns the button role for the specified <i>button</i>. This function returns <a href="qmessagebox.html#ButtonRole-enum">InvalidRole</a> if <i>button</i> is 0 or has not been added to the message box.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also </b><a href="qmessagebox.html#buttons">buttons</a>() and <a href="qmessagebox.html#addButton">addButton</a>().</p>
<!-- @@@buttonRole -->
<!-- $$$buttons[overload1]$$$buttons -->
<h3 class="fn"><a name="buttons"></a><span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> *> QMessageBox::<span class="name">buttons</span> () const</h3>
<p>Returns a list of all the buttons that have been added to the message box.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also </b><a href="qmessagebox.html#buttonRole">buttonRole</a>(), <a href="qmessagebox.html#addButton">addButton</a>(), and <a href="qmessagebox.html#removeButton">removeButton</a>().</p>
<!-- @@@buttons -->
<!-- $$$changeEvent[overload1]$$$changeEventQEvent* -->
<h3 class="fn"><a name="changeEvent"></a><span class="type">void</span> QMessageBox::<span class="name">changeEvent</span> ( <span class="type"><a href="qevent.html">QEvent</a></span> * <i>ev</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#changeEvent">QWidget::changeEvent</a>().</p>
<!-- @@@changeEvent -->
<!-- $$$clickedButton[overload1]$$$clickedButton -->
<h3 class="fn"><a name="clickedButton"></a><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> * QMessageBox::<span class="name">clickedButton</span> () const</h3>
<p>Returns the button that was clicked by the user, or 0 if the user hit the <b>Esc</b> key and no <a href="qmessagebox.html#setEscapeButton">escape button</a> was set.</p>
<p>If <a href="qmessagebox.html#exec">exec</a>() hasn't been called yet, returns 0.</p>
<p>Example:</p>
<pre class="cpp"> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span> messageBox(<span class="keyword">this</span>);
 <span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> <span class="operator">*</span>disconnectButton <span class="operator">=</span>
       messageBox<span class="operator">.</span><a href="qmessagebox.html#addButton">addButton</a>(tr(<span class="string">"Disconnect"</span>)<span class="operator">,</span> <span class="type"><a href="qmessagebox.html">QMessageBox</a></span><span class="operator">::</span>ActionRole);
 <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 messageBox<span class="operator">.</span><a href="qmessagebox.html#exec">exec</a>();
 <span class="keyword">if</span> (messageBox<span class="operator">.</span>clickedButton() <span class="operator">=</span><span class="operator">=</span> disconnectButton) {
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 }</pre>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#standardButton">standardButton</a>() and <a href="qmessagebox.html#button">button</a>().</p>
<!-- @@@clickedButton -->
<!-- $$$closeEvent[overload1]$$$closeEventQCloseEvent* -->
<h3 class="fn"><a name="closeEvent"></a><span class="type">void</span> QMessageBox::<span class="name">closeEvent</span> ( <span class="type"><a href="qcloseevent.html">QCloseEvent</a></span> * <i>e</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#closeEvent">QWidget::closeEvent</a>().</p>
<!-- @@@closeEvent -->
<!-- $$$critical[overload1]$$$criticalQWidget*constQString&constQString&StandardButtonsStandardButton -->
<h3 class="fn"><a name="critical"></a><span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> QMessageBox::<span class="name">critical</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>title</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButtons</a></span> <i>buttons</i> = Ok, <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> <i>defaultButton</i> = NoButton )<tt> [static]</tt></h3>
<p>Opens a critical message box with the given <i>title</i> and <i>text</i> in front of the specified <i>parent</i> widget.</p>
<p>The standard <i>buttons</i> are added to the message box. <i>defaultButton</i> specifies the button used when <b>Enter</b> is pressed. <i>defaultButton</i> must refer to a button that was given in <i>buttons</i>. If <i>defaultButton</i> is <a href="qmessagebox.html#StandardButton-enum">QMessageBox::NoButton</a>, <a href="qmessagebox.html">QMessageBox</a> chooses a suitable default automatically.</p>
<p>Returns the identity of the standard button that was clicked. If <b>Esc</b> was pressed instead, the <a href="qmessagebox.html#default-and-escape-keys">escape button</a> is returned.</p>
<p>The message box is an <a href="qt.html#WindowModality-enum">application modal</a> dialog box.</p>
<p><b>Warning:</b> Do not delete <i>parent</i> during the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the <a href="qmessagebox.html">QMessageBox</a> constructors.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#question">question</a>(), <a href="qmessagebox.html#warning">warning</a>(), and <a href="qmessagebox.html#information">information</a>().</p>
<!-- @@@critical -->
<!-- $$$defaultButton[overload1]$$$defaultButton -->
<h3 class="fn"><a name="defaultButton"></a><span class="type"><a href="qpushbutton.html">QPushButton</a></span> * QMessageBox::<span class="name">defaultButton</span> () const</h3>
<p>Returns the button that should be the message box's <a href="qpushbutton.html#default-prop">default button</a>. Returns 0 if no default button was set.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#setDefaultButton">setDefaultButton</a>(), <a href="qmessagebox.html#addButton">addButton</a>(), and <a href="qpushbutton.html#default-prop">QPushButton::setDefault</a>().</p>
<!-- @@@defaultButton -->
<!-- $$$escapeButton[overload1]$$$escapeButton -->
<h3 class="fn"><a name="escapeButton"></a><span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> * QMessageBox::<span class="name">escapeButton</span> () const</h3>
<p>Returns the button that is activated when escape is pressed.</p>
<p>By default, <a href="qmessagebox.html">QMessageBox</a> attempts to automatically detect an escape button as follows:</p>
<ol class="1">
<li>If there is only one button, it is made the escape button.</li>
<li>If there is a <a href="qmessagebox.html#StandardButton-enum">Cancel</a> button, it is made the escape button.</li>
<li>On Mac OS X only, if there is exactly one button with the role <a href="qmessagebox.html#ButtonRole-enum">QMessageBox::RejectRole</a>, it is made the escape button.</li>
</ol>
<p>When an escape button could not be automatically detected, pressing <b>Esc</b> has no effect.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#setEscapeButton">setEscapeButton</a>() and <a href="qmessagebox.html#addButton">addButton</a>().</p>
<!-- @@@escapeButton -->
<!-- $$$event[overload1]$$$eventQEvent* -->
<h3 class="fn"><a name="event"></a><span class="type">bool</span> QMessageBox::<span class="name">event</span> ( <span class="type"><a href="qevent.html">QEvent</a></span> * <i>e</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qobject.html#event">QObject::event</a>().</p>
<!-- @@@event -->
<!-- $$$exec[overload1]$$$exec -->
<h3 class="fn"><a name="exec"></a><span class="type">int</span> QMessageBox::<span class="name">exec</span> ()<tt> [slot]</tt></h3>
<p>Shows the message box as a <a href="qdialog.html#modal-dialogs">modal dialog</a>, blocking until the user closes it.</p>
<p>When using a <a href="qmessagebox.html">QMessageBox</a> with standard buttons, this functions returns a <a href="qmessagebox.html#StandardButton-enum">StandardButton</a> value indicating the standard button that was clicked. When using <a href="qmessagebox.html">QMessageBox</a> with custom buttons, this function returns an opaque value; use <a href="qmessagebox.html#clickedButton">clickedButton</a>() to determine which button was clicked.</p>
<p><b>Note:</b> The <a href="qdialog.html#result">result</a>() function returns also <a href="qmessagebox.html#StandardButton-enum">StandardButton</a> value instead of <a href="qdialog.html#DialogCode-enum">QDialog::DialogCode</a></p>
<p>Users cannot interact with any other window in the same application until they close the dialog, either by clicking a button or by using a mechanism provided by the window system.</p>
<p><b>See also </b><a href="qwidget.html#show">show</a>() and <a href="qdialog.html#result">result</a>().</p>
<!-- @@@exec -->
<!-- $$$information[overload1]$$$informationQWidget*constQString&constQString&StandardButtonsStandardButton -->
<h3 class="fn"><a name="information"></a><span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> QMessageBox::<span class="name">information</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>title</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButtons</a></span> <i>buttons</i> = Ok, <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> <i>defaultButton</i> = NoButton )<tt> [static]</tt></h3>
<p>Opens an information message box with the given <i>title</i> and <i>text</i> in front of the specified <i>parent</i> widget.</p>
<p>The standard <i>buttons</i> are added to the message box. <i>defaultButton</i> specifies the button used when <b>Enter</b> is pressed. <i>defaultButton</i> must refer to a button that was given in <i>buttons</i>. If <i>defaultButton</i> is <a href="qmessagebox.html#StandardButton-enum">QMessageBox::NoButton</a>, <a href="qmessagebox.html">QMessageBox</a> chooses a suitable default automatically.</p>
<p>Returns the identity of the standard button that was clicked. If <b>Esc</b> was pressed instead, the <a href="qmessagebox.html#default-and-escape-keys">escape button</a> is returned.</p>
<p>The message box is an <a href="qt.html#WindowModality-enum">application modal</a> dialog box.</p>
<p><b>Warning:</b> Do not delete <i>parent</i> during the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the <a href="qmessagebox.html">QMessageBox</a> constructors.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#question">question</a>(), <a href="qmessagebox.html#warning">warning</a>(), and <a href="qmessagebox.html#critical">critical</a>().</p>
<!-- @@@information -->
<!-- $$$keyPressEvent[overload1]$$$keyPressEventQKeyEvent* -->
<h3 class="fn"><a name="keyPressEvent"></a><span class="type">void</span> QMessageBox::<span class="name">keyPressEvent</span> ( <span class="type"><a href="qkeyevent.html">QKeyEvent</a></span> * <i>e</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget::keyPressEvent</a>().</p>
<!-- @@@keyPressEvent -->
<!-- $$$open[overload1]$$$openQObject*constchar* -->
<h3 class="fn"><a name="open"></a><span class="type">void</span> QMessageBox::<span class="name">open</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>receiver</i>, const <span class="type">char</span> * <i>member</i> )</h3>
<p>This is an overloaded function.</p>
<p>Opens the dialog and connects its <a href="qdialog.html#finished">finished</a>() or <a href="qmessagebox.html#buttonClicked">buttonClicked</a>() signal to the slot specified by <i>receiver</i> and <i>member</i>. If the slot in <i>member</i> has a pointer for its first parameter the connection is to <a href="qmessagebox.html#buttonClicked">buttonClicked</a>(), otherwise the connection is to <a href="qdialog.html#finished">finished</a>().</p>
<p>The signal will be disconnected from the slot when the dialog is closed.</p>
<!-- @@@open -->
<!-- $$$question[overload1]$$$questionQWidget*constQString&constQString&StandardButtonsStandardButton -->
<h3 class="fn"><a name="question"></a><span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> QMessageBox::<span class="name">question</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>title</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButtons</a></span> <i>buttons</i> = Ok, <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> <i>defaultButton</i> = NoButton )<tt> [static]</tt></h3>
<p>Opens a question message box with the given <i>title</i> and <i>text</i> in front of the specified <i>parent</i> widget.</p>
<p>The standard <i>buttons</i> are added to the message box. <i>defaultButton</i> specifies the button used when <b>Enter</b> is pressed. <i>defaultButton</i> must refer to a button that was given in <i>buttons</i>. If <i>defaultButton</i> is <a href="qmessagebox.html#StandardButton-enum">QMessageBox::NoButton</a>, <a href="qmessagebox.html">QMessageBox</a> chooses a suitable default automatically.</p>
<p>Returns the identity of the standard button that was clicked. If <b>Esc</b> was pressed instead, the <a href="qmessagebox.html#default-and-escape-keys">escape button</a> is returned.</p>
<p>The message box is an <a href="qt.html#WindowModality-enum">application modal</a> dialog box.</p>
<p><b>Warning:</b> Do not delete <i>parent</i> during the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the <a href="qmessagebox.html">QMessageBox</a> constructors.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#information">information</a>(), <a href="qmessagebox.html#warning">warning</a>(), and <a href="qmessagebox.html#critical">critical</a>().</p>
<!-- @@@question -->
<!-- $$$removeButton[overload1]$$$removeButtonQAbstractButton* -->
<h3 class="fn"><a name="removeButton"></a><span class="type">void</span> QMessageBox::<span class="name">removeButton</span> ( <span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> * <i>button</i> )</h3>
<p>Removes <i>button</i> from the button box without deleting it.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#addButton">addButton</a>() and <a href="qmessagebox.html#standardButtons-prop">setStandardButtons</a>().</p>
<!-- @@@removeButton -->
<!-- $$$resizeEvent[overload1]$$$resizeEventQResizeEvent* -->
<h3 class="fn"><a name="resizeEvent"></a><span class="type">void</span> QMessageBox::<span class="name">resizeEvent</span> ( <span class="type"><a href="qresizeevent.html">QResizeEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#resizeEvent">QWidget::resizeEvent</a>().</p>
<!-- @@@resizeEvent -->
<!-- $$$setDefaultButton[overload1]$$$setDefaultButtonQPushButton* -->
<h3 class="fn"><a name="setDefaultButton"></a><span class="type">void</span> QMessageBox::<span class="name">setDefaultButton</span> ( <span class="type"><a href="qpushbutton.html">QPushButton</a></span> * <i>button</i> )</h3>
<p>Sets the message box's <a href="qpushbutton.html#default-prop">default button</a> to <i>button</i>.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#defaultButton">defaultButton</a>(), <a href="qmessagebox.html#addButton">addButton</a>(), and <a href="qpushbutton.html#default-prop">QPushButton::setDefault</a>().</p>
<!-- @@@setDefaultButton -->
<!-- $$$setDefaultButton$$$setDefaultButtonStandardButton -->
<h3 class="fn"><a name="setDefaultButton-2"></a><span class="type">void</span> QMessageBox::<span class="name">setDefaultButton</span> ( <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> <i>button</i> )</h3>
<p>Sets the message box's <a href="qpushbutton.html#default-prop">default button</a> to <i>button</i>.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also </b><a href="qmessagebox.html#addButton">addButton</a>() and <a href="qpushbutton.html#default-prop">QPushButton::setDefault</a>().</p>
<!-- @@@setDefaultButton -->
<!-- $$$setEscapeButton[overload1]$$$setEscapeButtonQAbstractButton* -->
<h3 class="fn"><a name="setEscapeButton"></a><span class="type">void</span> QMessageBox::<span class="name">setEscapeButton</span> ( <span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> * <i>button</i> )</h3>
<p>Sets the button that gets activated when the <b>Escape</b> key is pressed to <i>button</i>.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#escapeButton">escapeButton</a>(), <a href="qmessagebox.html#addButton">addButton</a>(), and <a href="qmessagebox.html#clickedButton">clickedButton</a>().</p>
<!-- @@@setEscapeButton -->
<!-- $$$setEscapeButton$$$setEscapeButtonStandardButton -->
<h3 class="fn"><a name="setEscapeButton-2"></a><span class="type">void</span> QMessageBox::<span class="name">setEscapeButton</span> ( <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> <i>button</i> )</h3>
<p>Sets the buttons that gets activated when the <b>Escape</b> key is pressed to <i>button</i>.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also </b><a href="qmessagebox.html#addButton">addButton</a>() and <a href="qmessagebox.html#clickedButton">clickedButton</a>().</p>
<!-- @@@setEscapeButton -->
<!-- $$$setVisible[overload1]$$$setVisiblebool -->
<h3 class="fn"><a name="setVisible"></a><span class="type">void</span> QMessageBox::<span class="name">setVisible</span> ( <span class="type">bool</span> <i>visible</i> )<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#visible-prop">QWidget::setVisible</a>().</p>
<!-- @@@setVisible -->
<!-- $$$setWindowModality[overload1]$$$setWindowModalityQt::WindowModality -->
<h3 class="fn"><a name="setWindowModality"></a><span class="type">void</span> QMessageBox::<span class="name">setWindowModality</span> ( <span class="type"><a href="qt.html#WindowModality-enum">Qt::WindowModality</a></span> <i>windowModality</i> )</h3>
<p>This function shadows <a href="qwidget.html#windowModality-prop">QWidget::setWindowModality</a>().</p>
<p>Sets the modality of the message box to <i>windowModality</i>.</p>
<p>On Mac OS X, if the modality is set to <a href="qt.html#WindowModality-enum">Qt::WindowModal</a> and the message box has a parent, then the message box will be a <a href="qt.html#WindowType-enum">Qt::Sheet</a>, otherwise the message box will be a standard dialog.</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@setWindowModality -->
<!-- $$$setWindowTitle[overload1]$$$setWindowTitleconstQString& -->
<h3 class="fn"><a name="setWindowTitle"></a><span class="type">void</span> QMessageBox::<span class="name">setWindowTitle</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>title</i> )</h3>
<p>This function shadows <a href="qwidget.html#windowTitle-prop">QWidget::setWindowTitle</a>().</p>
<p>Sets the title of the message box to <i>title</i>. On Mac OS X, the window title is ignored (as required by the Mac OS X Guidelines).</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@setWindowTitle -->
<!-- $$$showEvent[overload1]$$$showEventQShowEvent* -->
<h3 class="fn"><a name="showEvent"></a><span class="type">void</span> QMessageBox::<span class="name">showEvent</span> ( <span class="type"><a href="qshowevent.html">QShowEvent</a></span> * <i>e</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#showEvent">QWidget::showEvent</a>().</p>
<!-- @@@showEvent -->
<!-- $$$standardButton[overload1]$$$standardButtonQAbstractButton* -->
<h3 class="fn"><a name="standardButton"></a><span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> QMessageBox::<span class="name">standardButton</span> ( <span class="type"><a href="qabstractbutton.html">QAbstractButton</a></span> * <i>button</i> ) const</h3>
<p>Returns the standard button enum value corresponding to the given <i>button</i>, or <a href="qmessagebox.html#StandardButton-enum">NoButton</a> if the given <i>button</i> isn't a standard button.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#button">button</a>() and <a href="qmessagebox.html#standardButtons-prop">standardButtons</a>().</p>
<!-- @@@standardButton -->
<!-- $$$warning[overload1]$$$warningQWidget*constQString&constQString&StandardButtonsStandardButton -->
<h3 class="fn"><a name="warning"></a><span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> QMessageBox::<span class="name">warning</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>title</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButtons</a></span> <i>buttons</i> = Ok, <span class="type"><a href="qmessagebox.html#StandardButton-enum">StandardButton</a></span> <i>defaultButton</i> = NoButton )<tt> [static]</tt></h3>
<p>Opens a warning message box with the given <i>title</i> and <i>text</i> in front of the specified <i>parent</i> widget.</p>
<p>The standard <i>buttons</i> are added to the message box. <i>defaultButton</i> specifies the button used when <b>Enter</b> is pressed. <i>defaultButton</i> must refer to a button that was given in <i>buttons</i>. If <i>defaultButton</i> is <a href="qmessagebox.html#StandardButton-enum">QMessageBox::NoButton</a>, <a href="qmessagebox.html">QMessageBox</a> chooses a suitable default automatically.</p>
<p>Returns the identity of the standard button that was clicked. If <b>Esc</b> was pressed instead, the <a href="qmessagebox.html#default-and-escape-keys">escape button</a> is returned.</p>
<p>The message box is an <a href="qt.html#WindowModality-enum">application modal</a> dialog box.</p>
<p><b>Warning:</b> Do not delete <i>parent</i> during the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the <a href="qmessagebox.html">QMessageBox</a> constructors.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qmessagebox.html#question">question</a>(), <a href="qmessagebox.html#information">information</a>(), and <a href="qmessagebox.html#critical">critical</a>().</p>
<!-- @@@warning -->
</div>
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
    <p>
      <acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
      subsidiaries. Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
 
     |