1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QApplication Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QApplication Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QApplication class manages the GUI application's control
flow and main settings. <a href="#details">More...</a></p>
<p>Inherits <a href="qcoreapplication.html">QCoreApplication</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qapplication.html#ColorSpec-enum">ColorSpec</a></b> { NormalColor, CustomColor, ManyColor }</li><li><div class="fn" />enum <b><a href="qapplication.html#Type-enum">Type</a></b> { Tty, GuiClient, GuiServer }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qapplication.html#QApplication">__init__</a></b> (<i>self</i>, list-of-str <i>argv</i>)</li><li><div class="fn" /><b><a href="qapplication.html#QApplication-2">__init__</a></b> (<i>self</i>, list-of-str <i>argv</i>, bool <i>GUIenabled</i>)</li><li><div class="fn" /><b><a href="qapplication.html#QApplication-3">__init__</a></b> (<i>self</i>, list-of-str <i>argv</i>, Type)</li><li><div class="fn" /><b><a href="qapplication.html#QApplication-4">__init__</a></b> (<i>self</i>, Display <i>display</i>, int <i>visual</i> = 0, int <i>colormap</i> = 0)</li><li><div class="fn" /><b><a href="qapplication.html#QApplication-5">__init__</a></b> (<i>self</i>, Display <i>dpy</i>, list-of-str <i>argv</i>, int <i>visual</i> = 0, int <i>cmap</i> = 0)</li><li><div class="fn" />bool <b><a href="qapplication.html#autoSipEnabled">autoSipEnabled</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qapplication.html#commitData">commitData</a></b> (<i>self</i>, QSessionManager <i>sm</i>)</li><li><div class="fn" />bool <b><a href="qapplication.html#event">event</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />QInputContext <b><a href="qapplication.html#inputContext">inputContext</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qapplication.html#isSessionRestored">isSessionRestored</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qapplication.html#notify">notify</a></b> (<i>self</i>, QObject, QEvent)</li><li><div class="fn" /><b><a href="qapplication.html#saveState">saveState</a></b> (<i>self</i>, QSessionManager <i>sm</i>)</li><li><div class="fn" />QString <b><a href="qapplication.html#sessionId">sessionId</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qapplication.html#sessionKey">sessionKey</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qapplication.html#setAutoSipEnabled">setAutoSipEnabled</a></b> (<i>self</i>, bool <i>enabled</i>)</li><li><div class="fn" /><b><a href="qapplication.html#setInputContext">setInputContext</a></b> (<i>self</i>, QInputContext)</li><li><div class="fn" /><b><a href="qapplication.html#setStyleSheet">setStyleSheet</a></b> (<i>self</i>, QString <i>sheet</i>)</li><li><div class="fn" />QString <b><a href="qapplication.html#styleSheet">styleSheet</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qapplication.html#x11EventFilter">x11EventFilter</a></b> (<i>self</i>, sip.voidptr)</li><li><div class="fn" />int <b><a href="qapplication.html#x11ProcessEvent">x11ProcessEvent</a></b> (<i>self</i>, sip.voidptr)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" /><b><a href="qapplication.html#aboutQt">aboutQt</a></b> ()</li><li><div class="fn" />QWidget <b><a href="qapplication.html#activeModalWidget">activeModalWidget</a></b> ()</li><li><div class="fn" />QWidget <b><a href="qapplication.html#activePopupWidget">activePopupWidget</a></b> ()</li><li><div class="fn" />QWidget <b><a href="qapplication.html#activeWindow">activeWindow</a></b> ()</li><li><div class="fn" /><b><a href="qapplication.html#alert">alert</a></b> (QWidget <i>widget</i>, int <i>msecs</i> = 0)</li><li><div class="fn" />list-of-QWidget <b><a href="qapplication.html#allWidgets">allWidgets</a></b> ()</li><li><div class="fn" /><b><a href="qapplication.html#beep">beep</a></b> ()</li><li><div class="fn" /><b><a href="qapplication.html#changeOverrideCursor">changeOverrideCursor</a></b> (QCursor)</li><li><div class="fn" />QClipboard <b><a href="qapplication.html#clipboard">clipboard</a></b> ()</li><li><div class="fn" /><b><a href="qapplication.html#closeAllWindows">closeAllWindows</a></b> ()</li><li><div class="fn" />int <b><a href="qapplication.html#colorSpec">colorSpec</a></b> ()</li><li><div class="fn" />int <b><a href="qapplication.html#cursorFlashTime">cursorFlashTime</a></b> ()</li><li><div class="fn" />QDesktopWidget <b><a href="qapplication.html#desktop">desktop</a></b> ()</li><li><div class="fn" />bool <b><a href="qapplication.html#desktopSettingsAware">desktopSettingsAware</a></b> ()</li><li><div class="fn" />int <b><a href="qapplication.html#doubleClickInterval">doubleClickInterval</a></b> ()</li><li><div class="fn" />int <b><a href="qapplication.html#exec">exec_</a></b> ()</li><li><div class="fn" />QWidget <b><a href="qapplication.html#focusWidget">focusWidget</a></b> ()</li><li><div class="fn" />QFont <b><a href="qapplication.html#font">font</a></b> ()</li><li><div class="fn" />QFont <b><a href="qapplication.html#font-2">font</a></b> (QWidget)</li><li><div class="fn" />QFont <b><a href="qapplication.html#font-3">font</a></b> (str <i>className</i>)</li><li><div class="fn" />QFontMetrics <b><a href="qapplication.html#fontMetrics">fontMetrics</a></b> ()</li><li><div class="fn" />QSize <b><a href="qapplication.html#globalStrut">globalStrut</a></b> ()</li><li><div class="fn" />bool <b><a href="qapplication.html#isEffectEnabled">isEffectEnabled</a></b> (Qt.UIEffect)</li><li><div class="fn" />bool <b><a href="qapplication.html#isLeftToRight">isLeftToRight</a></b> ()</li><li><div class="fn" />bool <b><a href="qapplication.html#isRightToLeft">isRightToLeft</a></b> ()</li><li><div class="fn" />Qt.LayoutDirection <b><a href="qapplication.html#keyboardInputDirection">keyboardInputDirection</a></b> ()</li><li><div class="fn" />int <b><a href="qapplication.html#keyboardInputInterval">keyboardInputInterval</a></b> ()</li><li><div class="fn" />QLocale <b><a href="qapplication.html#keyboardInputLocale">keyboardInputLocale</a></b> ()</li><li><div class="fn" />Qt.KeyboardModifiers <b><a href="qapplication.html#keyboardModifiers">keyboardModifiers</a></b> ()</li><li><div class="fn" />Qt.LayoutDirection <b><a href="qapplication.html#layoutDirection">layoutDirection</a></b> ()</li><li><div class="fn" />Qt.MouseButtons <b><a href="qapplication.html#mouseButtons">mouseButtons</a></b> ()</li><li><div class="fn" />QCursor <b><a href="qapplication.html#overrideCursor">overrideCursor</a></b> ()</li><li><div class="fn" />QPalette <b><a href="qapplication.html#palette">palette</a></b> ()</li><li><div class="fn" />QPalette <b><a href="qapplication.html#palette-2">palette</a></b> (QWidget)</li><li><div class="fn" />QPalette <b><a href="qapplication.html#palette-3">palette</a></b> (str <i>className</i>)</li><li><div class="fn" />Qt.KeyboardModifiers <b><a href="qapplication.html#queryKeyboardModifiers">queryKeyboardModifiers</a></b> ()</li><li><div class="fn" />bool <b><a href="qapplication.html#quitOnLastWindowClosed">quitOnLastWindowClosed</a></b> ()</li><li><div class="fn" /><b><a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a></b> ()</li><li><div class="fn" /><b><a href="qapplication.html#setActiveWindow">setActiveWindow</a></b> (QWidget <i>act</i>)</li><li><div class="fn" /><b><a href="qapplication.html#setColorSpec">setColorSpec</a></b> (int)</li><li><div class="fn" /><b><a href="qapplication.html#setCursorFlashTime">setCursorFlashTime</a></b> (int)</li><li><div class="fn" /><b><a href="qapplication.html#setDesktopSettingsAware">setDesktopSettingsAware</a></b> (bool)</li><li><div class="fn" /><b><a href="qapplication.html#setDoubleClickInterval">setDoubleClickInterval</a></b> (int)</li><li><div class="fn" /><b><a href="qapplication.html#setEffectEnabled">setEffectEnabled</a></b> (Qt.UIEffect <i>effect</i>, bool <i>enabled</i> = True)</li><li><div class="fn" /><b><a href="qapplication.html#setFont">setFont</a></b> (QFont <i>font</i>, str <i>className</i> = None)</li><li><div class="fn" /><b><a href="qapplication.html#setGlobalStrut">setGlobalStrut</a></b> (QSize)</li><li><div class="fn" /><b><a href="qapplication.html#setGraphicsSystem">setGraphicsSystem</a></b> (QString)</li><li><div class="fn" /><b><a href="qapplication.html#setKeyboardInputInterval">setKeyboardInputInterval</a></b> (int)</li><li><div class="fn" /><b><a href="qapplication.html#setLayoutDirection">setLayoutDirection</a></b> (Qt.LayoutDirection <i>direction</i>)</li><li><div class="fn" /><b><a href="qapplication.html#setOverrideCursor">setOverrideCursor</a></b> (QCursor)</li><li><div class="fn" /><b><a href="qapplication.html#setPalette">setPalette</a></b> (QPalette <i>palette</i>, str <i>className</i> = None)</li><li><div class="fn" /><b><a href="qapplication.html#setQuitOnLastWindowClosed">setQuitOnLastWindowClosed</a></b> (bool <i>quit</i>)</li><li><div class="fn" /><b><a href="qapplication.html#setStartDragDistance">setStartDragDistance</a></b> (int <i>l</i>)</li><li><div class="fn" /><b><a href="qapplication.html#setStartDragTime">setStartDragTime</a></b> (int <i>ms</i>)</li><li><div class="fn" /><b><a href="qapplication.html#setStyle">setStyle</a></b> (QStyle)</li><li><div class="fn" />QStyle <b><a href="qapplication.html#setStyle-2">setStyle</a></b> (QString)</li><li><div class="fn" /><b><a href="qapplication.html#setWheelScrollLines">setWheelScrollLines</a></b> (int)</li><li><div class="fn" /><b><a href="qapplication.html#setWindowIcon">setWindowIcon</a></b> (QIcon <i>icon</i>)</li><li><div class="fn" />int <b><a href="qapplication.html#startDragDistance">startDragDistance</a></b> ()</li><li><div class="fn" />int <b><a href="qapplication.html#startDragTime">startDragTime</a></b> ()</li><li><div class="fn" />QStyle <b><a href="qapplication.html#style">style</a></b> ()</li><li><div class="fn" /><b><a href="qapplication.html#syncX">syncX</a></b> ()</li><li><div class="fn" />QWidget <b><a href="qapplication.html#topLevelAt">topLevelAt</a></b> (QPoint <i>p</i>)</li><li><div class="fn" />QWidget <b><a href="qapplication.html#topLevelAt-2">topLevelAt</a></b> (int <i>x</i>, int <i>y</i>)</li><li><div class="fn" />list-of-QWidget <b><a href="qapplication.html#topLevelWidgets">topLevelWidgets</a></b> ()</li><li><div class="fn" />Type <b><a href="qapplication.html#type">type</a></b> ()</li><li><div class="fn" />int <b><a href="qapplication.html#wheelScrollLines">wheelScrollLines</a></b> ()</li><li><div class="fn" />QWidget <b><a href="qapplication.html#widgetAt">widgetAt</a></b> (QPoint <i>p</i>)</li><li><div class="fn" />QWidget <b><a href="qapplication.html#widgetAt-2">widgetAt</a></b> (int <i>x</i>, int <i>y</i>)</li><li><div class="fn" />QIcon <b><a href="qapplication.html#windowIcon">windowIcon</a></b> ()</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qapplication.html#commitDataRequest">commitDataRequest</a></b> (QSessionManager&)</li><li><div class="fn" />void <b><a href="qapplication.html#focusChanged">focusChanged</a></b> (QWidget *,QWidget *)</li><li><div class="fn" />void <b><a href="qapplication.html#fontDatabaseChanged">fontDatabaseChanged</a></b> ()</li><li><div class="fn" />void <b><a href="qapplication.html#lastWindowClosed">lastWindowClosed</a></b> ()</li><li><div class="fn" />void <b><a href="qapplication.html#saveStateRequest">saveStateRequest</a></b> (QSessionManager&)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QApplication class manages the GUI application's control
flow and main settings.</p>
<p>QApplication contains the main event loop, where all events from
the window system and other sources are processed and dispatched.
It also handles the application's initialization, finalization, and
provides session management. In addition, QApplication handles most
of the system-wide and application-wide settings.</p>
<p>For any GUI application using Qt, there is precisely <b>one</b>
QApplication object, no matter whether the application has 0, 1, 2
or more windows at any given time. For non-GUI Qt applications, use
<a href="qcoreapplication.html">QCoreApplication</a> instead, as it
does not depend on the <a href="qtgui.html">QtGui</a> library.</p>
<p>The QApplication object is accessible through the <a href="qcoreapplication.html#instance">instance</a>() function that
returns a pointer equivalent to the global <a href="qtgui.html#qApp-var">qApp</a> pointer.</p>
<p>QApplication's main areas of responsibility are:</p>
<ul>
<li>It initializes the application with the user's desktop settings
such as <a href="qapplication.html#palette">palette</a>(), <a href="qapplication.html#font">font</a>() and <a href="qapplication.html#doubleClickInterval-prop">doubleClickInterval</a>().
It keeps track of these properties in case the user changes the
desktop globally, for example through some kind of control
panel.</li>
<li>It performs event handling, meaning that it receives events
from the underlying window system and dispatches them to the
relevant widgets. By using <a href="qcoreapplication.html#sendEvent">sendEvent</a>() and <a href="qcoreapplication.html#postEvent">postEvent</a>() you can send your
own events to widgets.</li>
<li>It parses common command line arguments and sets its internal
state accordingly. See the <a href="qapplication.html#QApplication">constructor documentation</a>
below for more details.</li>
<li>It defines the application's look and feel, which is
encapsulated in a <a href="qstyle.html">QStyle</a> object. This can
be changed at runtime with <a href="qapplication.html#setStyle">setStyle</a>().</li>
<li>It specifies how the application is to allocate colors. See
<a href="qapplication.html#setColorSpec">setColorSpec</a>() for
details.</li>
<li>It provides localization of strings that are visible to the
user via <a href="qcoreapplication.html#translate">translate</a>().</li>
<li>It provides some magical objects like the <a href="qapplication.html#desktop">desktop</a>() and the <a href="qapplication.html#clipboard">clipboard</a>().</li>
<li>It knows about the application's windows. You can ask which
widget is at a certain position using <a href="qapplication.html#widgetAt">widgetAt</a>(), get a list of <a href="qapplication.html#topLevelWidgets">topLevelWidgets</a>() and
<a href="qapplication.html#closeAllWindows">closeAllWindows</a>(),
etc.</li>
<li>It manages the application's mouse cursor handling, see
<a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>()</li>
<li>On the X window system, it provides functions to flush and sync
the communication stream, see <a class="compat" href="qapplication-qt3.html#flushX">flushX</a>() and
<a href="qapplication.html#syncX">syncX</a>().</li>
<li>It provides support for sophisticated <a href="session.html">session management</a>. This makes it possible for
applications to terminate gracefully when the user logs out, to
cancel a shutdown process if termination isn't possible and even to
preserve the entire application's state for a future session. See
<a href="qapplication.html#isSessionRestored">isSessionRestored</a>(),
<a href="qapplication.html#sessionId">sessionId</a>() and <a href="qapplication.html#commitData">commitData</a>() and <a href="qapplication.html#saveState">saveState</a>() for details.</li>
</ul>
<p>Since the QApplication object does so much initialization, it
<i>must</i> be created before any other objects related to the user
interface are created. QApplication also deals with common command
line arguments. Hence, it is usually a good idea to create it
<i>before</i> any interpretation or modification of <tt>argv</tt>
is done in the application itself.</p>
<table class="generic">
<thead>
<tr class="qt-style">
<th colspan="2">Groups of functions</th>
</tr>
</thead>
<tr class="odd" valign="top">
<td>System settings</td>
<td><a href="qapplication.html#desktopSettingsAware">desktopSettingsAware</a>(),
<a href="qapplication.html#setDesktopSettingsAware">setDesktopSettingsAware</a>(),
<a href="qapplication.html#cursorFlashTime-prop">cursorFlashTime</a>(),
<a href="qapplication.html#cursorFlashTime-prop">setCursorFlashTime</a>(),
<a href="qapplication.html#doubleClickInterval-prop">doubleClickInterval</a>(),
<a href="qapplication.html#doubleClickInterval-prop">setDoubleClickInterval</a>(),
<a href="qapplication.html#keyboardInputInterval-prop">setKeyboardInputInterval</a>(),
<a href="qapplication.html#wheelScrollLines-prop">wheelScrollLines</a>(),
<a href="qapplication.html#wheelScrollLines-prop">setWheelScrollLines</a>(),
<a href="qapplication.html#palette">palette</a>(), <a href="qapplication.html#setPalette">setPalette</a>(), <a href="qapplication.html#font">font</a>(), <a href="qapplication.html#setFont">setFont</a>(), <a href="qapplication.html#fontMetrics">fontMetrics</a>().</td>
</tr>
<tr class="even" valign="top">
<td>Event handling</td>
<td><a href="qapplication.html#exec">exec_</a>(), <a href="qcoreapplication.html#processEvents">processEvents</a>(), <a href="qcoreapplication.html#exit">exit</a>(), <a href="qcoreapplication.html#quit">quit</a>(). <a href="qcoreapplication.html#sendEvent">sendEvent</a>(), <a href="qcoreapplication.html#postEvent">postEvent</a>(), <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>(),
<a href="qcoreapplication.html#removePostedEvents">removePostedEvents</a>(),
<a href="qcoreapplication.html#hasPendingEvents">hasPendingEvents</a>(),
<a href="qapplication.html#notify">notify</a>(), <a href="qapplication.html#macEventFilter">macEventFilter</a>(), <a href="qapplication.html#qwsEventFilter">qwsEventFilter</a>(), <a href="qapplication.html#x11EventFilter">x11EventFilter</a>(), <a href="qapplication.html#x11ProcessEvent">x11ProcessEvent</a>(), <a href="qcoreapplication.html#winEventFilter">winEventFilter</a>().</td>
</tr>
<tr class="odd" valign="top">
<td>GUI Styles</td>
<td><a href="qapplication.html#style">style</a>(), <a href="qapplication.html#setStyle">setStyle</a>().</td>
</tr>
<tr class="even" valign="top">
<td>Color usage</td>
<td><a href="qapplication.html#colorSpec">colorSpec</a>(), <a href="qapplication.html#setColorSpec">setColorSpec</a>(), <a href="qapplication.html#qwsSetCustomColors">qwsSetCustomColors</a>().</td>
</tr>
<tr class="odd" valign="top">
<td>Text handling</td>
<td><a href="qcoreapplication.html#installTranslator">installTranslator</a>(),
<a href="qcoreapplication.html#removeTranslator">removeTranslator</a>()
<a href="qcoreapplication.html#translate">translate</a>().</td>
</tr>
<tr class="even" valign="top">
<td>Widgets</td>
<td><a href="qapplication.html#allWidgets">allWidgets</a>(),
<a href="qapplication.html#topLevelWidgets">topLevelWidgets</a>(),
<a href="qapplication.html#desktop">desktop</a>(), <a href="qapplication.html#activePopupWidget">activePopupWidget</a>(),
<a href="qapplication.html#activeModalWidget">activeModalWidget</a>(),
<a href="qapplication.html#clipboard">clipboard</a>(), <a href="qapplication.html#focusWidget">focusWidget</a>(), <a href="qapplication.html#activeWindow">activeWindow</a>(), <a href="qapplication.html#widgetAt">widgetAt</a>().</td>
</tr>
<tr class="odd" valign="top">
<td>Advanced cursor handling</td>
<td><a href="qapplication.html#overrideCursor">overrideCursor</a>(), <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>(),
<a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>().</td>
</tr>
<tr class="even" valign="top">
<td>X Window System synchronization</td>
<td><a class="compat" href="qapplication-qt3.html#flushX">flushX</a>(), <a href="qapplication.html#syncX">syncX</a>().</td>
</tr>
<tr class="odd" valign="top">
<td>Session management</td>
<td><a href="qapplication.html#isSessionRestored">isSessionRestored</a>(),
<a href="qapplication.html#sessionId">sessionId</a>(), <a href="qapplication.html#commitData">commitData</a>(), <a href="qapplication.html#saveState">saveState</a>().</td>
</tr>
<tr class="even" valign="top">
<td>Miscellaneous</td>
<td><a href="qapplication.html#closeAllWindows">closeAllWindows</a>(), <a href="qcoreapplication.html#startingUp">startingUp</a>(), <a href="qcoreapplication.html#closingDown">closingDown</a>(), <a href="qapplication.html#type">type</a>().</td>
</tr>
</table>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="ColorSpec-enum" />QApplication.ColorSpec</h3><table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QApplication.NormalColor</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">the default color allocation policy</td>
</tr>
<tr>
<td class="topAlign"><tt>QApplication.CustomColor</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">the same as NormalColor for X11; allocates
colors to a palette on demand under Windows</td>
</tr>
<tr>
<td class="topAlign"><tt>QApplication.ManyColor</tt></td>
<td class="topAlign"><tt>2</tt></td>
<td class="topAlign">the right choice for applications that use
thousands of colors</td>
</tr>
</table>
<p>See <a href="qapplication.html#setColorSpec">setColorSpec</a>()
for full details.</p>
<h3 class="fn"><a name="Type-enum" />QApplication.Type</h3><table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QApplication.Tty</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">a console application</td>
</tr>
<tr>
<td class="topAlign"><tt>QApplication.GuiClient</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">a GUI client application</td>
</tr>
<tr>
<td class="topAlign"><tt>QApplication.GuiServer</tt></td>
<td class="topAlign"><tt>2</tt></td>
<td class="topAlign">a GUI server application (for Qt for Embedded
Linux)</td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QApplication" />QApplication.__init__ (<i>self</i>, list-of-str <i>argv</i>)</h3><p>Initializes the window system and constructs an application
object with <i>argc</i> command line arguments in <i>argv</i>.</p>
<p><b>Warning:</b> The data referred to by <i>argc</i> and
<i>argv</i> must stay valid for the entire lifetime of the <a href="qapplication.html">QApplication</a> object. In addition,
<i>argc</i> must be greater than zero and <i>argv</i> must contain
at least one valid character string.</p>
<p>The global <tt>qApp</tt> pointer refers to this application
object. Only one application object should be created.</p>
<p>This application object must be constructed before any <a href="qpaintdevice.html">paint devices</a> (including widgets, pixmaps,
bitmaps etc.).</p>
<p><b>Note:</b> <i>argc</i> and <i>argv</i> might be changed as Qt
removes command line arguments that it recognizes.</p>
<p>Qt debugging options (not available if Qt was compiled without
the QT_DEBUG flag defined):</p>
<ul>
<li>-nograb, tells Qt that it must never grab the mouse or the
keyboard.</li>
<li>-dograb (only under X11), running under a debugger can cause an
implicit -nograb, use -dograb to override.</li>
<li>-sync (only under X11), switches to synchronous mode for
debugging.</li>
</ul>
<p>See <a href="debug.html">Debugging Techniques</a> for a more
detailed explanation.</p>
<p>All Qt programs automatically support the following command line
options:</p>
<ul>
<li>-style= <i>style</i>, sets the application GUI style. Possible
values are <tt>motif</tt>, <tt>windows</tt>, and <tt>platinum</tt>.
If you compiled Qt with additional styles or have additional styles
as plugins these will be available to the <tt>-style</tt> command
line option.</li>
<li>-style <i>style</i>, is the same as listed above.</li>
<li>-stylesheet= <i>stylesheet</i>, sets the application <a href="qapplication.html#styleSheet-prop">styleSheet</a>. The value must
be a path to a file that contains the Style Sheet. <b>Note:</b>
Relative URLs in the Style Sheet file are relative to the Style
Sheet file's path.</li>
<li>-stylesheet <i>stylesheet</i>, is the same as listed
above.</li>
<li>-session= <i>session</i>, restores the application from an
earlier <a href="session.html">session</a>.</li>
<li>-session <i>session</i>, is the same as listed above.</li>
<li>-widgetcount, prints debug message at the end about number of
widgets left undestroyed and maximum number of widgets existed at
the same time</li>
<li>-reverse, sets the application's layout direction to <a href="qt.html#LayoutDirection-enum">Qt.RightToLeft</a></li>
<li>-graphicssystem, sets the backend to be used for on-screen
widgets and QPixmaps. Available options are <tt>raster</tt> and
<tt>opengl</tt>.</li>
<li>-qmljsdebugger=, activates the QML/JS debugger with a specified
port. The value must be of format port:1234[,block], where block is
optional and will make the application wait until a debugger
connects to it.</li>
</ul>
<p>The X11 version of Qt supports some traditional X11 command line
options:</p>
<ul>
<li>-display <i>display</i>, sets the X display (default is
$DISPLAY).</li>
<li>-geometry <i>geometry</i>, sets the client geometry of the
first window that is shown.</li>
<li>-fn or <tt>-font</tt> <i>font</i>, defines the application
font. The font should be specified using an X logical font
description. Note that this option is ignored when Qt is built with
fontconfig support enabled.</li>
<li>-bg or <tt>-background</tt> <i>color</i>, sets the default
background color and an application palette (light and dark shades
are calculated).</li>
<li>-fg or <tt>-foreground</tt> <i>color</i>, sets the default
foreground color.</li>
<li>-btn or <tt>-button</tt> <i>color</i>, sets the default button
color.</li>
<li>-name <i>name</i>, sets the application name.</li>
<li>-title <i>title</i>, sets the application title.</li>
<li>-visual <tt>TrueColor</tt>, forces the application to use a
TrueColor visual on an 8-bit display.</li>
<li>-ncols <i>count</i>, limits the number of colors allocated in
the color cube on an 8-bit display, if the application is using the
<a href="qapplication.html#ColorSpec-enum">QApplication.ManyColor</a>
color specification. If <i>count</i> is 216 then a 6x6x6 color cube
is used (i.e. 6 levels of red, 6 of green, and 6 of blue); for
other values, a cube approximately proportional to a 2x3x1 cube is
used.</li>
<li>-cmap, causes the application to install a private color map on
an 8-bit display.</li>
<li>-im, sets the input method server (equivalent to setting the
XMODIFIERS environment variable)</li>
<li>-inputstyle, defines how the input is inserted into the given
widget, e.g., <tt>onTheSpot</tt> makes the input appear directly in
the widget, while <tt>overTheSpot</tt> makes the input appear in a
box floating over the widget and is not inserted until the editing
is done.</li>
</ul>
<a id="x11-notes" name="x11-notes" />
<h4>X11 Notes</h4>
<p>If <a href="qapplication.html">QApplication</a> fails to open
the X11 display, it will terminate the process. This behavior is
consistent with most X11 applications.</p>
<p><b>See also</b> <a href="qcoreapplication.html#arguments">arguments</a>().</p>
<h3 class="fn"><a name="QApplication-2" />QApplication.__init__ (<i>self</i>, list-of-str <i>argv</i>, bool <i>GUIenabled</i>)</h3><p>Constructs an application object with <i>argc</i> command line
arguments in <i>argv</i>. If <i>GUIenabled</i> is true, a GUI
application is constructed, otherwise a non-GUI (console)
application is created.</p>
<p><b>Warning:</b> The data referred to by <i>argc</i> and
<i>argv</i> must stay valid for the entire lifetime of the <a href="qapplication.html">QApplication</a> object. In addition,
<i>argc</i> must be greater than zero and <i>argv</i> must contain
at least one valid character string.</p>
<p>Set <i>GUIenabled</i> to false for programs without a graphical
user interface that should be able to run without a window
system.</p>
<p>On X11, the window system is initialized if <i>GUIenabled</i> is
true. If <i>GUIenabled</i> is false, the application does not
connect to the X server. On Windows and Mac OS, currently the
window system is always initialized, regardless of the value of
GUIenabled. This may change in future versions of Qt.</p>
<p>The following example shows how to create an application that
uses a graphical interface when available.</p>
<pre class="cpp">
<span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span><span class="operator">*</span>argv)
{
<span class="preprocessor">#ifdef Q_WS_X11</span>
<span class="type">bool</span> useGUI <span class="operator">=</span> getenv(<span class="string">"DISPLAY"</span>) <span class="operator">!</span><span class="operator">=</span> <span class="number">0</span>;
<span class="preprocessor">#else</span>
<span class="type">bool</span> useGUI <span class="operator">=</span> <span class="keyword">true</span>;
<span class="preprocessor">#endif</span>
<span class="type"><a href="qapplication.html">QApplication</a></span> app(argc<span class="operator">,</span> argv<span class="operator">,</span> useGUI);
<span class="keyword">if</span> (useGUI) {
<span class="comment">// start GUI version</span>
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
} <span class="keyword">else</span> {
<span class="comment">// start non-GUI version</span>
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
}
<span class="keyword">return</span> app<span class="operator">.</span>exec();
}
</pre>
<h3 class="fn"><a name="QApplication-3" />QApplication.__init__ (<i>self</i>, list-of-str <i>argv</i>, <a href="qapplication.html#Type-enum">Type</a>)</h3><p>Constructs an application object with <i>argc</i> command line
arguments in <i>argv</i>.</p>
<p><b>Warning:</b> The data referred to by <i>argc</i> and
<i>argv</i> must stay valid for the entire lifetime of the <a href="qapplication.html">QApplication</a> object. In addition,
<i>argc</i> must be greater than zero and <i>argv</i> must contain
at least one valid character string.</p>
<p>With Qt for Embedded Linux, passing <a href="qapplication.html#Type-enum">QApplication.GuiServer</a> for
<i>type</i> makes this application the server (equivalent to
running with the <tt>-qws</tt> option).</p>
<h3 class="fn"><a name="QApplication-4" />QApplication.__init__ (<i>self</i>, Display <i>display</i>, int <i>visual</i> = 0, int <i>colormap</i> = 0)</h3><p>Creates an application, given an already open display
<i>display</i>. If <i>visual</i> and <i>colormap</i> are non-zero,
the application will use those values as the default Visual and
Colormap contexts.</p>
<p><b>Warning:</b> Qt only supports TrueColor visuals at depths
higher than 8 bits-per-pixel.</p>
<p>This function is only available on X11.</p>
<h3 class="fn"><a name="QApplication-5" />QApplication.__init__ (<i>self</i>, Display <i>dpy</i>, list-of-str <i>argv</i>, int <i>visual</i> = 0, int <i>cmap</i> = 0)</h3><p>Creates an application, given an already open <i>display</i> and
using <i>argc</i> command line arguments in <i>argv</i>. If
<i>visual</i> and <i>colormap</i> are non-zero, the application
will use those values as the default Visual and Colormap
contexts.</p>
<p><b>Warning:</b> Qt only supports TrueColor visuals at depths
higher than 8 bits-per-pixel.</p>
<p>This function is only available on X11.</p>
<h3 class="fn"><a name="aboutQt" />QApplication.aboutQt ()</h3><p>This method is also a Qt slot with the C++ signature <tt>void aboutQt()</tt>.</p><p>Displays a simple message box about Qt. 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>This function is a convenience slot for <a href="qmessagebox.html#aboutQt">QMessageBox.aboutQt</a>().</p>
<h3 class="fn"><a name="activeModalWidget" /><a href="qwidget.html">QWidget</a> QApplication.activeModalWidget ()</h3><p>Returns the active modal widget.</p>
<p>A modal widget is a special top-level widget which is a subclass
of <a href="qdialog.html">QDialog</a> that specifies the modal
parameter of the constructor as true. A modal widget must be closed
before the user can continue with other parts of the program.</p>
<p>Modal widgets are organized in a stack. This function returns
the active modal widget at the top of the stack.</p>
<p><b>See also</b> <a href="qapplication.html#activePopupWidget">activePopupWidget</a>() and
<a href="qapplication.html#topLevelWidgets">topLevelWidgets</a>().</p>
<h3 class="fn"><a name="activePopupWidget" /><a href="qwidget.html">QWidget</a> QApplication.activePopupWidget ()</h3><p>Returns the active popup widget.</p>
<p>A popup widget is a special top-level widget that sets the
<tt>Qt.WType_Popup</tt> widget flag, e.g. the <a href="qmenu.html">QMenu</a> widget. When the application opens a popup
widget, all events are sent to the popup. Normal widgets and modal
widgets cannot be accessed before the popup widget is closed.</p>
<p>Only other popup widgets may be opened when a popup widget is
shown. The popup widgets are organized in a stack. This function
returns the active popup widget at the top of the stack.</p>
<p><b>See also</b> <a href="qapplication.html#activeModalWidget">activeModalWidget</a>() and
<a href="qapplication.html#topLevelWidgets">topLevelWidgets</a>().</p>
<h3 class="fn"><a name="activeWindow" /><a href="qwidget.html">QWidget</a> QApplication.activeWindow ()</h3><p>Returns the application top-level window that has the keyboard
input focus, or 0 if no application window has the focus. There
might be an activeWindow() even if there is no <a href="qapplication.html#focusWidget">focusWidget</a>(), for example if
no widget in that window accepts key events.</p>
<p><b>See also</b> <a href="qapplication.html#setActiveWindow">setActiveWindow</a>(), <a href="qwidget.html#setFocus">QWidget.setFocus</a>(), <a href="qwidget.html#focus-prop">QWidget.hasFocus</a>(), and <a href="qapplication.html#focusWidget">focusWidget</a>().</p>
<h3 class="fn"><a name="alert" />QApplication.alert (<a href="qwidget.html">QWidget</a> <i>widget</i>, int <i>msecs</i> = 0)</h3><p>Causes an alert to be shown for <i>widget</i> if the window is
not the active window. The alert is shown for <i>msec</i>
miliseconds. If <i>msec</i> is zero (the default), then the alert
is shown indefinitely until the window becomes active again.</p>
<p>Currently this function does nothing on Qt for Embedded
Linux.</p>
<p>On Mac OS X, this works more at the application level and will
cause the application icon to bounce in the dock.</p>
<p>On Windows, this causes the window's taskbar entry to flash for
a time. If <i>msec</i> is zero, the flashing will stop and the
taskbar entry will turn a different color (currently orange).</p>
<p>On X11, this will cause the window to be marked as "demands
attention", the window must not be hidden (i.e. not have hide()
called on it, but be visible in some sort of way) in order for this
to work.</p>
<p>This function was introduced in Qt 4.3.</p>
<h3 class="fn"><a name="allWidgets" />list-of-QWidget QApplication.allWidgets ()</h3><p>Returns a list of all the widgets in the application.</p>
<p>The list is empty (<a href="qlist.html#isEmpty">QList.isEmpty</a>()) if there are no
widgets.</p>
<p><b>Note:</b> Some of the widgets may be hidden.</p>
<p>Example:</p>
<pre class="cpp">
<span class="type">void</span> updateAllWidgets()
{
foreach (<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>widget<span class="operator">,</span> <span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">.</span>allWidgets())
widget<span class="operator">-</span><span class="operator">></span>update();
}
</pre>
<p><b>See also</b> <a href="qapplication.html#topLevelWidgets">topLevelWidgets</a>() and
<a href="qwidget.html#visible-prop">QWidget.isVisible</a>().</p>
<h3 class="fn"><a name="autoSipEnabled" />bool QApplication.autoSipEnabled (<i>self</i>)</h3><h3 class="fn"><a name="beep" />QApplication.beep ()</h3><p>Sounds the bell, using the default volume and sound. The
function is <i>not</i> available in Qt for Embedded Linux.</p>
<h3 class="fn"><a name="changeOverrideCursor" />QApplication.changeOverrideCursor (<a href="qcursor.html">QCursor</a>)</h3><p>Changes the currently active application override cursor to
<i>cursor</i>.</p>
<p>This function has no effect if <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>() was
not called.</p>
<p><b>See also</b> <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>(),
<a href="qapplication.html#overrideCursor">overrideCursor</a>(),
<a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>(),
and <a href="qwidget.html#cursor-prop">QWidget.setCursor</a>().</p>
<h3 class="fn"><a name="clipboard" /><a href="qclipboard.html">QClipboard</a> QApplication.clipboard ()</h3><p>Returns a pointer to the application global clipboard.</p>
<p><b>Note:</b> The <a href="qapplication.html">QApplication</a>
object should already be constructed before accessing the
clipboard.</p>
<h3 class="fn"><a name="closeAllWindows" />QApplication.closeAllWindows ()</h3><p>This method is also a Qt slot with the C++ signature <tt>void closeAllWindows()</tt>.</p><p>Closes all top-level windows.</p>
<p>This function is particularly useful for applications with many
top-level windows. It could, for example, be connected to a
<b>Exit</b> entry in the <b>File</b> menu:</p>
<pre class="cpp">
exitAct <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qaction.html">QAction</a></span>(tr(<span class="string">"E&xit"</span>)<span class="operator">,</span> <span class="keyword">this</span>);
exitAct<span class="operator">-</span><span class="operator">></span>setShortcuts(<span class="type"><a href="qkeysequence.html">QKeySequence</a></span><span class="operator">.</span>Quit);
exitAct<span class="operator">-</span><span class="operator">></span>setStatusTip(tr(<span class="string">"Exit the application"</span>));
connect(exitAct<span class="operator">,</span> SIGNAL(triggered())<span class="operator">,</span> qApp<span class="operator">,</span> SLOT(closeAllWindows()));
</pre>
<p>The windows are closed in random order, until one window does
not accept the close event. The application quits when the last
window was successfully closed; this can be turned off by setting
<a href="qapplication.html#quitOnLastWindowClosed-prop">quitOnLastWindowClosed</a>
to false.</p>
<p><b>See also</b> <a href="qapplication.html#quitOnLastWindowClosed-prop">quitOnLastWindowClosed</a>,
<a href="qapplication.html#lastWindowClosed">lastWindowClosed</a>(),
<a href="qwidget.html#close">QWidget.close</a>(), <a href="qwidget.html#closeEvent">QWidget.closeEvent</a>(), <a href="qapplication.html#lastWindowClosed">lastWindowClosed</a>(),
<a href="qcoreapplication.html#quit">quit</a>(), <a href="qapplication.html#topLevelWidgets">topLevelWidgets</a>(), and
<a href="qwidget.html#isWindow">QWidget.isWindow</a>().</p>
<h3 class="fn"><a name="colorSpec" />int QApplication.colorSpec ()</h3><p>Returns the color specification.</p>
<p><b>See also</b> <a href="qapplication.html#setColorSpec">QApplication.setColorSpec</a>().</p>
<h3 class="fn"><a name="commitData" />QApplication.commitData (<i>self</i>, <a href="qsessionmanager.html">QSessionManager</a> <i>sm</i>)</h3><p>This function deals with <a href="session.html">session
management</a>. It is invoked when the <a href="qsessionmanager.html">QSessionManager</a> wants the application to
commit all its data.</p>
<p>Usually this means saving all open files, after getting
permission from the user. Furthermore you may want to provide a
means by which the user can cancel the shutdown.</p>
<p>You should not exit the application within this function.
Instead, the session manager may or may not do this afterwards,
depending on the context.</p>
<p><b>Warning:</b> Within this function, no user interaction is
possible, <i>unless</i> you ask the <i>manager</i> for explicit
permission. See <a href="qsessionmanager.html#allowsInteraction">QSessionManager.allowsInteraction</a>()
and <a href="qsessionmanager.html#allowsErrorInteraction">QSessionManager.allowsErrorInteraction</a>()
for details and example usage.</p>
<p>The default implementation requests interaction and sends a
close event to all visible top-level widgets. If any event was
rejected, the shutdown is canceled.</p>
<p><b>See also</b> <a href="qapplication.html#isSessionRestored">isSessionRestored</a>(),
<a href="qapplication.html#sessionId">sessionId</a>(), <a href="qapplication.html#saveState">saveState</a>(), and <a href="session.html">Session Management</a>.</p>
<h3 class="fn"><a name="cursorFlashTime" />int QApplication.cursorFlashTime ()</h3><h3 class="fn"><a name="desktop" /><a href="qdesktopwidget.html">QDesktopWidget</a> QApplication.desktop ()</h3><p>Returns the desktop widget (also called the root window).</p>
<p>The desktop may be composed of multiple screens, so it would be
incorrect, for example, to attempt to <i>center</i> some widget in
the desktop's geometry. <a href="qdesktopwidget.html">QDesktopWidget</a> has various functions for
obtaining useful geometries upon the desktop, such as <a href="qdesktopwidget.html#screenGeometry">QDesktopWidget.screenGeometry</a>()
and <a href="qdesktopwidget.html#availableGeometry">QDesktopWidget.availableGeometry</a>().</p>
<p>On X11, it is also possible to draw on the desktop.</p>
<h3 class="fn"><a name="desktopSettingsAware" />bool QApplication.desktopSettingsAware ()</h3><p>Returns true if Qt is set to use the system's standard colors,
fonts, etc.; otherwise returns false. The default is true.</p>
<p><b>See also</b> <a href="qapplication.html#setDesktopSettingsAware">setDesktopSettingsAware</a>().</p>
<h3 class="fn"><a name="doubleClickInterval" />int QApplication.doubleClickInterval ()</h3><h3 class="fn"><a name="event" />bool QApplication.event (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p>
<h3 class="fn"><a name="exec" />int QApplication.exec_ ()</h3><p>Enters the main event loop and waits until <a href="qcoreapplication.html#exit">exit</a>() is called, then returns the
value that was set to <a href="qcoreapplication.html#exit">exit</a>() (which is 0 if <a href="qcoreapplication.html#exit">exit</a>() is called via <a href="qcoreapplication.html#quit">quit</a>()).</p>
<p>It is necessary to call this function to start event handling.
The main event loop receives events from the window system and
dispatches these to the application widgets.</p>
<p>Generally, no user interaction can take place before calling
exec(). As a special case, modal widgets like <a href="qmessagebox.html">QMessageBox</a> can be used before calling
exec(), because modal widgets call exec() to start a local event
loop.</p>
<p>To make your application perform idle processing, i.e.,
executing a special function whenever there are no pending events,
use a <a href="qtimer.html">QTimer</a> with 0 timeout. More
advanced idle processing schemes can be achieved using <a href="qcoreapplication.html#processEvents">processEvents</a>().</p>
<p>We recommend that you connect clean-up code to the <a href="qcoreapplication.html#aboutToQuit">aboutToQuit()</a> signal,
instead of putting it in your application's <tt>main()</tt>
function. This is because, on some platforms the
QApplication.exec() call may not return. For example, on the
Windows platform, when the user logs off, the system terminates the
process after Qt closes all top-level windows. Hence, there is
<i>no guarantee</i> that the application will have time to exit its
event loop and execute code at the end of the <tt>main()</tt>
function, after the QApplication.exec() call.</p>
<p><b>See also</b> <a href="qapplication.html#quitOnLastWindowClosed-prop">quitOnLastWindowClosed</a>,
<a href="qcoreapplication.html#quit">quit</a>(), <a href="qcoreapplication.html#exit">exit</a>(), <a href="qcoreapplication.html#processEvents">processEvents</a>(), and
<a href="qcoreapplication.html#exec">QCoreApplication.exec</a>().</p>
<h3 class="fn"><a name="focusWidget" /><a href="qwidget.html">QWidget</a> QApplication.focusWidget ()</h3><p>Returns the application widget that has the keyboard input
focus, or 0 if no widget in this application has the focus.</p>
<p><b>See also</b> <a href="qwidget.html#setFocus">QWidget.setFocus</a>(), <a href="qwidget.html#focus-prop">QWidget.hasFocus</a>(), <a href="qapplication.html#activeWindow">activeWindow</a>(), and <a href="qapplication.html#focusChanged">focusChanged</a>().</p>
<h3 class="fn"><a name="font" /><a href="qfont.html">QFont</a> QApplication.font ()</h3><p>Returns the default application font.</p>
<p><b>See also</b> <a href="qapplication.html#setFont">setFont</a>(), <a href="qapplication.html#fontMetrics">fontMetrics</a>(), and <a href="qwidget.html#font-prop">QWidget.font</a>().</p>
<h3 class="fn"><a name="font-2" /><a href="qfont.html">QFont</a> QApplication.font (<a href="qwidget.html">QWidget</a>)</h3><p>This is an overloaded function.</p>
<p>Returns the default font for the <i>widget</i>.</p>
<p><b>See also</b> <a href="qapplication.html#fontMetrics">fontMetrics</a>() and <a href="qwidget.html#font-prop">QWidget.setFont</a>().</p>
<h3 class="fn"><a name="font-3" /><a href="qfont.html">QFont</a> QApplication.font (str <i>className</i>)</h3><p>This is an overloaded function.</p>
<p>Returns the font for widgets of the given <i>className</i>.</p>
<p><b>See also</b> <a href="qapplication.html#setFont">setFont</a>() and <a href="qwidget.html#font-prop">QWidget.font</a>().</p>
<h3 class="fn"><a name="fontMetrics" /><a href="qfontmetrics.html">QFontMetrics</a> QApplication.fontMetrics ()</h3><p>Returns display (screen) font metrics for the application
font.</p>
<p><b>See also</b> <a href="qapplication.html#font">font</a>(),
<a href="qapplication.html#setFont">setFont</a>(), <a href="qwidget.html#fontMetrics">QWidget.fontMetrics</a>(), and <a href="qpainter.html#fontMetrics">QPainter.fontMetrics</a>().</p>
<h3 class="fn"><a name="globalStrut" /><a href="qsize.html">QSize</a> QApplication.globalStrut ()</h3><h3 class="fn"><a name="inputContext" /><a href="qinputcontext.html">QInputContext</a> QApplication.inputContext (<i>self</i>)</h3><p>Returns the <a href="qinputcontext.html">QInputContext</a>
instance used by the application.</p>
<p><b>See also</b> <a href="qapplication.html#setInputContext">setInputContext</a>().</p>
<h3 class="fn"><a name="isEffectEnabled" />bool QApplication.isEffectEnabled (<a href="qt.html#UIEffect-enum">Qt.UIEffect</a>)</h3><p>Returns true if <i>effect</i> is enabled; otherwise returns
false.</p>
<p>By default, Qt will try to use the desktop settings. To prevent
this, call setDesktopSettingsAware(false).</p>
<p><b>Note:</b> All effects are disabled on screens running at less
than 16-bit color depth.</p>
<p><b>See also</b> <a href="qapplication.html#setEffectEnabled">setEffectEnabled</a>() and
<a href="qt.html#UIEffect-enum">Qt.UIEffect</a>.</p>
<h3 class="fn"><a name="isLeftToRight" />bool QApplication.isLeftToRight ()</h3><p>Returns true if the application's layout direction is <a href="qt.html#LayoutDirection-enum">Qt.LeftToRight</a>; otherwise
returns false.</p>
<p><b>See also</b> <a href="qapplication.html#layoutDirection-prop">layoutDirection</a>() and
<a href="qapplication.html#isRightToLeft">isRightToLeft</a>().</p>
<h3 class="fn"><a name="isRightToLeft" />bool QApplication.isRightToLeft ()</h3><p>Returns true if the application's layout direction is <a href="qt.html#LayoutDirection-enum">Qt.RightToLeft</a>; otherwise
returns false.</p>
<p><b>See also</b> <a href="qapplication.html#layoutDirection-prop">layoutDirection</a>() and
<a href="qapplication.html#isLeftToRight">isLeftToRight</a>().</p>
<h3 class="fn"><a name="isSessionRestored" />bool QApplication.isSessionRestored (<i>self</i>)</h3><p>Returns true if the application has been restored from an
earlier <a href="session.html">session</a>; otherwise returns
false.</p>
<p><b>See also</b> <a href="qapplication.html#sessionId">sessionId</a>(), <a href="qapplication.html#commitData">commitData</a>(), and <a href="qapplication.html#saveState">saveState</a>().</p>
<h3 class="fn"><a name="keyboardInputDirection" /><a href="qt.html#LayoutDirection-enum">Qt.LayoutDirection</a> QApplication.keyboardInputDirection ()</h3><p>Returns the current keyboard input direction.</p>
<p>This function was introduced in Qt 4.2.</p>
<h3 class="fn"><a name="keyboardInputInterval" />int QApplication.keyboardInputInterval ()</h3><h3 class="fn"><a name="keyboardInputLocale" /><a href="qlocale.html">QLocale</a> QApplication.keyboardInputLocale ()</h3><p>Returns the current keyboard input locale.</p>
<p>This function was introduced in Qt 4.2.</p>
<h3 class="fn"><a name="keyboardModifiers" /><a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> QApplication.keyboardModifiers ()</h3><p>Returns the current state of the modifier keys on the keyboard.
The current state is updated sychronously as the event queue is
emptied of events that will spontaneously change the keyboard state
(<a href="qevent.html#Type-enum">QEvent.KeyPress</a> and <a href="qevent.html#Type-enum">QEvent.KeyRelease</a> events).</p>
<p>It should be noted this may not reflect the actual keys held on
the input device at the time of calling but rather the modifiers as
last reported in one of the above events. If no keys are being held
<a href="qt.html#KeyboardModifier-enum">Qt.NoModifier</a> is
returned.</p>
<p><b>See also</b> <a href="qapplication.html#mouseButtons">mouseButtons</a>() and <a href="qapplication.html#queryKeyboardModifiers">queryKeyboardModifiers</a>().</p>
<h3 class="fn"><a name="layoutDirection" /><a href="qt.html#LayoutDirection-enum">Qt.LayoutDirection</a> QApplication.layoutDirection ()</h3><h3 class="fn"><a name="mouseButtons" /><a href="qt-mousebuttons.html">Qt.MouseButtons</a> QApplication.mouseButtons ()</h3><p>Returns the current state of the buttons on the mouse. The
current state is updated syncronously as the event queue is emptied
of events that will spontaneously change the mouse state (<a href="qevent.html#Type-enum">QEvent.MouseButtonPress</a> and <a href="qevent.html#Type-enum">QEvent.MouseButtonRelease</a> events).</p>
<p>It should be noted this may not reflect the actual buttons held
on the input device at the time of calling but rather the mouse
buttons as last reported in one of the above events. If no mouse
buttons are being held <a href="qt.html#MouseButton-enum">Qt.NoButton</a> is returned.</p>
<p><b>See also</b> <a href="qapplication.html#keyboardModifiers">keyboardModifiers</a>().</p>
<h3 class="fn"><a name="notify" />bool QApplication.notify (<i>self</i>, <a href="qobject.html">QObject</a>, <a href="qevent.html">QEvent</a>)</h3><p>Reimplemented from <a href="qcoreapplication.html#notify">QCoreApplication.notify</a>().</p>
<h3 class="fn"><a name="overrideCursor" /><a href="qcursor.html">QCursor</a> QApplication.overrideCursor ()</h3><p>Returns the active application override cursor.</p>
<p>This function returns 0 if no application cursor has been
defined (i.e. the internal cursor stack is empty).</p>
<p><b>See also</b> <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>() and
<a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>().</p>
<h3 class="fn"><a name="palette" /><a href="qpalette.html">QPalette</a> QApplication.palette ()</h3><p>Returns the application palette.</p>
<p><b>See also</b> <a href="qapplication.html#setPalette">setPalette</a>() and <a href="qwidget.html#palette-prop">QWidget.palette</a>().</p>
<h3 class="fn"><a name="palette-2" /><a href="qpalette.html">QPalette</a> QApplication.palette (<a href="qwidget.html">QWidget</a>)</h3><p>This is an overloaded function.</p>
<p>If a <i>widget</i> is passed, the default palette for the
widget's class is returned. This may or may not be the application
palette. In most cases there is no special palette for certain
types of widgets, but one notable exception is the popup menu under
Windows, if the user has defined a special background color for
menus in the display settings.</p>
<p><b>See also</b> <a href="qapplication.html#setPalette">setPalette</a>() and <a href="qwidget.html#palette-prop">QWidget.palette</a>().</p>
<h3 class="fn"><a name="palette-3" /><a href="qpalette.html">QPalette</a> QApplication.palette (str <i>className</i>)</h3><p>This is an overloaded function.</p>
<p>Returns the palette for widgets of the given
<i>className</i>.</p>
<p><b>See also</b> <a href="qapplication.html#setPalette">setPalette</a>() and <a href="qwidget.html#palette-prop">QWidget.palette</a>().</p>
<h3 class="fn"><a name="queryKeyboardModifiers" /><a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> QApplication.queryKeyboardModifiers ()</h3><p>Queries and returns the state of the modifier keys on the
keyboard. Unlike keyboardModifiers, this method returns the actual
keys held on the input device at the time of calling the
method.</p>
<p>It does not rely on the keypress events having been received by
this process, which makes it possible to check the modifiers while
moving a window, for instance. Note that in most cases, you should
use <a href="qapplication.html#keyboardModifiers">keyboardModifiers</a>(),
which is faster and more accurate since it contains the state of
the modifiers as they were when the currently processed event was
received.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also</b> <a href="qapplication.html#keyboardModifiers">keyboardModifiers</a>().</p>
<h3 class="fn"><a name="quitOnLastWindowClosed" />bool QApplication.quitOnLastWindowClosed ()</h3><h3 class="fn"><a name="restoreOverrideCursor" />QApplication.restoreOverrideCursor ()</h3><p>Undoes the last <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>().</p>
<p>If <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>() has
been called twice, calling restoreOverrideCursor() will activate
the first cursor set. Calling this function a second time restores
the original widgets' cursors.</p>
<p><b>See also</b> <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>() and
<a href="qapplication.html#overrideCursor">overrideCursor</a>().</p>
<h3 class="fn"><a name="saveState" />QApplication.saveState (<i>self</i>, <a href="qsessionmanager.html">QSessionManager</a> <i>sm</i>)</h3><p>This function deals with <a href="session.html">session
management</a>. It is invoked when the <a href="qsessionmanager.html">session manager</a> wants the application to
preserve its state for a future session.</p>
<p>For example, a text editor would create a temporary file that
includes the current contents of its edit buffers, the location of
the cursor and other aspects of the current editing session.</p>
<p>You should never exit the application within this function.
Instead, the session manager may or may not do this afterwards,
depending on the context. Futhermore, most session managers will
very likely request a saved state immediately after the application
has been started. This permits the session manager to learn about
the application's restart policy.</p>
<p><b>Warning:</b> Within this function, no user interaction is
possible, <i>unless</i> you ask the <i>manager</i> for explicit
permission. See <a href="qsessionmanager.html#allowsInteraction">QSessionManager.allowsInteraction</a>()
and <a href="qsessionmanager.html#allowsErrorInteraction">QSessionManager.allowsErrorInteraction</a>()
for details.</p>
<p><b>See also</b> <a href="qapplication.html#isSessionRestored">isSessionRestored</a>(),
<a href="qapplication.html#sessionId">sessionId</a>(), <a href="qapplication.html#commitData">commitData</a>(), and <a href="session.html">Session Management</a>.</p>
<h3 class="fn"><a name="sessionId" />QString QApplication.sessionId (<i>self</i>)</h3><p>Returns the current <a href="session.html">session's</a>
identifier.</p>
<p>If the application has been restored from an earlier session,
this identifier is the same as it was in that previous session. The
session identifier is guaranteed to be unique both for different
applications and for different instances of the same
application.</p>
<p><b>See also</b> <a href="qapplication.html#isSessionRestored">isSessionRestored</a>(),
<a href="qapplication.html#sessionKey">sessionKey</a>(), <a href="qapplication.html#commitData">commitData</a>(), and <a href="qapplication.html#saveState">saveState</a>().</p>
<h3 class="fn"><a name="sessionKey" />QString QApplication.sessionKey (<i>self</i>)</h3><p>Returns the session key in the current <a href="session.html">session</a>.</p>
<p>If the application has been restored from an earlier session,
this key is the same as it was when the previous session ended.</p>
<p>The session key changes with every call of <a href="qapplication.html#commitData">commitData</a>() or <a href="qapplication.html#saveState">saveState</a>().</p>
<p><b>See also</b> <a href="qapplication.html#isSessionRestored">isSessionRestored</a>(),
<a href="qapplication.html#sessionId">sessionId</a>(), <a href="qapplication.html#commitData">commitData</a>(), and <a href="qapplication.html#saveState">saveState</a>().</p>
<h3 class="fn"><a name="setActiveWindow" />QApplication.setActiveWindow (<a href="qwidget.html">QWidget</a> <i>act</i>)</h3><p>Sets the active window to the <i>active</i> widget in response
to a system event. The function is called from the platform
specific event handlers.</p>
<p><b>Warning:</b> This function does <i>not</i> set the keyboard
focus to the active widget. Call <a href="qwidget.html#activateWindow">QWidget.activateWindow</a>()
instead.</p>
<p>It sets the <a href="qapplication.html#activeWindow">activeWindow</a>() and <a href="qapplication.html#focusWidget">focusWidget</a>() attributes and
sends proper <a href="qevent.html#Type-enum">WindowActivate</a>/<a href="qevent.html#Type-enum">WindowDeactivate</a> and <a href="qevent.html#Type-enum">FocusIn</a>/<a href="qevent.html#Type-enum">FocusOut</a> events to all appropriate
widgets. The window will then be painted in active state (e.g.
cursors in line edits will blink), and it will have tool tips
enabled.</p>
<p><b>See also</b> <a href="qapplication.html#activeWindow">activeWindow</a>() and <a href="qwidget.html#activateWindow">QWidget.activateWindow</a>().</p>
<h3 class="fn"><a name="setAutoSipEnabled" />QApplication.setAutoSipEnabled (<i>self</i>, bool <i>enabled</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setAutoSipEnabled(const bool)</tt>.</p><h3 class="fn"><a name="setColorSpec" />QApplication.setColorSpec (int)</h3><p>Sets the color specification for the application to
<i>spec</i>.</p>
<p>The color specification controls how the application allocates
colors when run on a display with a limited amount of colors, e.g.
8 bit / 256 color displays.</p>
<p>The color specification must be set before you create the
<a href="qapplication.html">QApplication</a> object.</p>
<p>The options are:</p>
<ul>
<li><a href="qapplication.html#ColorSpec-enum">QApplication.NormalColor</a>.
This is the default color allocation strategy. Use this option if
your application uses buttons, menus, texts and pixmaps with few
colors. With this option, the application uses system global
colors. This works fine for most applications under X11, but on the
Windows platform, it may cause dithering of non-standard
colors.</li>
<li><a href="qapplication.html#ColorSpec-enum">QApplication.CustomColor</a>.
Use this option if your application needs a small number of custom
colors. On X11, this option is the same as <a href="qapplication.html#ColorSpec-enum">NormalColor</a>. On Windows, Qt
creates a Windows palette, and allocates colors to it on
demand.</li>
<li><a href="qapplication.html#ColorSpec-enum">QApplication.ManyColor</a>. Use
this option if your application is very color hungry, e.g., it
requires thousands of colors.<br />
Under X11 the effect is:
<ul>
<li>For 256-color displays which have at best a 256 color true
color visual, the default visual is used, and colors are allocated
from a color cube. The color cube is the 6x6x6 (216 color) "Web
palette" (the red, green, and blue components always have one of
the following values: 0x00, 0x33, 0x66, 0x99, 0xCC, or 0xFF), but
the number of colors can be changed by the <i>-ncols</i> option.
The user can force the application to use the true color visual
with the <a href="qapplication.html#QApplication">-visual</a>
option.</li>
<li>For 256-color displays which have a true color visual with more
than 256 colors, use that visual. Silicon Graphics X servers this
feature, for example. They provide an 8 bit visual by default but
can deliver true color when asked.</li>
</ul>
<p>On Windows, Qt creates a Windows palette, and fills it with a
color cube.</p>
</li>
</ul>
<p>Be aware that the <a href="qapplication.html#ColorSpec-enum">CustomColor</a> and <a href="qapplication.html#ColorSpec-enum">ManyColor</a> choices may lead
to colormap flashing: The foreground application gets (most) of the
available colors, while the background windows will look less
attractive.</p>
<p>Example:</p>
<pre class="cpp">
<span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>)
{
<span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">.</span>setColorSpec(<span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">.</span>ManyColor);
<span class="type"><a href="qapplication.html">QApplication</a></span> app(argc<span class="operator">,</span> argv);
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
<span class="keyword">return</span> app<span class="operator">.</span>exec();
}
</pre>
<p><b>See also</b> <a href="qapplication.html#colorSpec">colorSpec</a>().</p>
<h3 class="fn"><a name="setCursorFlashTime" />QApplication.setCursorFlashTime (int)</h3><h3 class="fn"><a name="setDesktopSettingsAware" />QApplication.setDesktopSettingsAware (bool)</h3><p>Sets whether Qt should use the system's standard colors, fonts,
etc., to <i>on</i>. By default, this is true.</p>
<p>This function must be called before creating the <a href="qapplication.html">QApplication</a> object, like this:</p>
<pre class="cpp">
<span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>)
{
<span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">.</span>setDesktopSettingsAware(<span class="keyword">false</span>);
<span class="type"><a href="qapplication.html">QApplication</a></span> app(argc<span class="operator">,</span> argv);
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
<span class="keyword">return</span> app<span class="operator">.</span>exec();
}
</pre>
<p><b>See also</b> <a href="qapplication.html#desktopSettingsAware">desktopSettingsAware</a>().</p>
<h3 class="fn"><a name="setDoubleClickInterval" />QApplication.setDoubleClickInterval (int)</h3><h3 class="fn"><a name="setEffectEnabled" />QApplication.setEffectEnabled (<a href="qt.html#UIEffect-enum">Qt.UIEffect</a> <i>effect</i>, bool <i>enabled</i> = True)</h3><p>Enables the UI effect <i>effect</i> if <i>enable</i> is true,
otherwise the effect will not be used.</p>
<p><b>Note:</b> All effects are disabled on screens running at less
than 16-bit color depth.</p>
<p><b>See also</b> <a href="qapplication.html#isEffectEnabled">isEffectEnabled</a>(), <a href="qt.html#UIEffect-enum">Qt.UIEffect</a>, and <a href="qapplication.html#setDesktopSettingsAware">setDesktopSettingsAware</a>().</p>
<h3 class="fn"><a name="setFont" />QApplication.setFont (<a href="qfont.html">QFont</a> <i>font</i>, str <i>className</i> = None)</h3><p>Changes the default application font to <i>font</i>. If
<i>className</i> is passed, the change applies only to classes that
inherit <i>className</i> (as reported by <a href="qobject.html#inherits">QObject.inherits</a>()).</p>
<p>On application start-up, the default font depends on the window
system. It can vary depending on both the window system version and
the locale. This function lets you override the default font; but
overriding may be a bad idea because, for example, some locales
need extra large fonts to support their special characters.</p>
<p><b>Warning:</b> Do not use this function in conjunction with
<a href="stylesheet.html">Qt Style Sheets</a>. The font of an
application can be customized using the "font" style sheet
property. To set a bold font for all QPushButtons, set the
application <a href="qapplication.html#styleSheet-prop">styleSheet</a>() as "<a href="qpushbutton.html">QPushButton</a> { font: bold }"</p>
<p><b>See also</b> <a href="qapplication.html#font">font</a>(),
<a href="qapplication.html#fontMetrics">fontMetrics</a>(), and
<a href="qwidget.html#font-prop">QWidget.setFont</a>().</p>
<h3 class="fn"><a name="setGlobalStrut" />QApplication.setGlobalStrut (<a href="qsize.html">QSize</a>)</h3><h3 class="fn"><a name="setGraphicsSystem" />QApplication.setGraphicsSystem (QString)</h3><p>Sets the default graphics backend to <i>system</i>, which will
be used for on-screen widgets and QPixmaps. The available systems
are <tt>"native"</tt>, <tt>"raster"</tt> and <tt>"opengl"</tt>.</p>
<p>There are several ways to set the graphics backend, in order of
decreasing precedence:</p>
<ul>
<li>the application commandline <tt>-graphicssystem</tt>
switch</li>
<li>QApplication.setGraphicsSystem()</li>
<li>the QT_GRAPHICSSYSTEM environment variable</li>
<li>the Qt configure <tt>-graphicssystem</tt> switch</li>
</ul>
<p>If the highest precedence switch sets an invalid name, the error
will be ignored and the default backend will be used.</p>
<p><b>Warning:</b> This function is only effective before the
<a href="qapplication.html">QApplication</a> constructor is
called.</p>
<p><b>Note:</b> The <tt>"opengl"</tt> option is currently
experimental.</p>
<p>This function was introduced in Qt 4.5.</p>
<h3 class="fn"><a name="setInputContext" />QApplication.setInputContext (<i>self</i>, <a href="qinputcontext.html">QInputContext</a>)</h3><p>The <i>QInputContext</i> argument has it's ownership transferred to Qt.</p><p>This function replaces the <a href="qinputcontext.html">QInputContext</a> instance used by the
application with <i>inputContext</i>.</p>
<p>Qt takes ownership of the given <i>inputContext</i>.</p>
<p><b>See also</b> <a href="qapplication.html#inputContext">inputContext</a>().</p>
<h3 class="fn"><a name="setKeyboardInputInterval" />QApplication.setKeyboardInputInterval (int)</h3><h3 class="fn"><a name="setLayoutDirection" />QApplication.setLayoutDirection (<a href="qt.html#LayoutDirection-enum">Qt.LayoutDirection</a> <i>direction</i>)</h3><h3 class="fn"><a name="setOverrideCursor" />QApplication.setOverrideCursor (<a href="qcursor.html">QCursor</a>)</h3><p>Sets the application override cursor to <i>cursor</i>.</p>
<p>Application override cursors are intended for showing the user
that the application is in a special state, for example during an
operation that might take some time.</p>
<p>This cursor will be displayed in all the application's widgets
until <a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>()
or another setOverrideCursor() is called.</p>
<p>Application cursors are stored on an internal stack.
setOverrideCursor() pushes the cursor onto the stack, and <a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>()
pops the active cursor off the stack. <a href="qapplication.html#changeOverrideCursor">changeOverrideCursor</a>()
changes the curently active application override cursor.</p>
<p>Every setOverrideCursor() must eventually be followed by a
corresponding <a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>(),
otherwise the stack will never be emptied.</p>
<p>Example:</p>
<pre class="cpp">
<span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">.</span>setOverrideCursor(<span class="type"><a href="qcursor.html">QCursor</a></span>(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>WaitCursor));
calculateHugeMandelbrot(); <span class="comment">// lunch time...</span>
<span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">.</span><a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>();
</pre>
<p><b>See also</b> <a href="qapplication.html#overrideCursor">overrideCursor</a>(), <a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>(),
<a href="qapplication.html#changeOverrideCursor">changeOverrideCursor</a>(),
and <a href="qwidget.html#cursor-prop">QWidget.setCursor</a>().</p>
<h3 class="fn"><a name="setPalette" />QApplication.setPalette (<a href="qpalette.html">QPalette</a> <i>palette</i>, str <i>className</i> = None)</h3><p>Changes the default application palette to <i>palette</i>.</p>
<p>If <i>className</i> is passed, the change applies only to
widgets that inherit <i>className</i> (as reported by <a href="qobject.html#inherits">QObject.inherits</a>()). If
<i>className</i> is left 0, the change affects all widgets, thus
overriding any previously set class specific palettes.</p>
<p>The palette may be changed according to the current GUI style in
<a href="qstyle.html#polish">QStyle.polish</a>().</p>
<p><b>Warning:</b> Do not use this function in conjunction with
<a href="stylesheet.html">Qt Style Sheets</a>. When using style
sheets, the palette of a widget can be customized using the
"color", "background-color", "selection-color",
"selection-background-color" and "alternate-background-color".</p>
<p><b>Note:</b> Some styles do not use the palette for all drawing,
for instance, if they make use of native theme engines. This is the
case for the Windows XP, Windows Vista, and Mac OS X styles.</p>
<p><b>See also</b> <a href="qwidget.html#palette-prop">QWidget.setPalette</a>(), <a href="qapplication.html#palette">palette</a>(), and <a href="qstyle.html#polish">QStyle.polish</a>().</p>
<h3 class="fn"><a name="setQuitOnLastWindowClosed" />QApplication.setQuitOnLastWindowClosed (bool <i>quit</i>)</h3><h3 class="fn"><a name="setStartDragDistance" />QApplication.setStartDragDistance (int <i>l</i>)</h3><h3 class="fn"><a name="setStartDragTime" />QApplication.setStartDragTime (int <i>ms</i>)</h3><h3 class="fn"><a name="setStyle" />QApplication.setStyle (<a href="qstyle.html">QStyle</a>)</h3><p>The <i>QStyle</i> argument has it's ownership transferred to Qt.</p><p>Sets the application's GUI style to <i>style</i>. Ownership of
the style object is transferred to <a href="qapplication.html">QApplication</a>, so <a href="qapplication.html">QApplication</a> will delete the style object
on application exit or when a new style is set and the old style is
still the parent of the application object.</p>
<p>Example usage:</p>
<pre class="cpp">
<span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">.</span>setStyle(<span class="keyword">new</span> <span class="type"><a href="qwindowsstyle.html">QWindowsStyle</a></span>);
</pre>
<p>When switching application styles, the color palette is set back
to the initial colors or the system defaults. This is necessary
since certain styles have to adapt the color palette to be fully
style-guide compliant.</p>
<p>Setting the style before a palette has been se, i.e., before
creating <a href="qapplication.html">QApplication</a>, will cause
the application to use <a href="qstyle.html#standardPalette">QStyle.standardPalette</a>() for the
palette.</p>
<p><b>Warning:</b> Qt style sheets are currently not supported for
custom <a href="qstyle.html">QStyle</a> subclasses. We plan to
address this in some future release.</p>
<p><b>See also</b> <a href="qapplication.html#style">style</a>(),
<a href="qstyle.html">QStyle</a>, <a href="qapplication.html#setPalette">setPalette</a>(), and <a href="qapplication.html#desktopSettingsAware">desktopSettingsAware</a>().</p>
<h3 class="fn"><a name="setStyle-2" /><a href="qstyle.html">QStyle</a> QApplication.setStyle (QString)</h3><p>This is an overloaded function.</p>
<p>Requests a <a href="qstyle.html">QStyle</a> object for
<i>style</i> from the <a href="qstylefactory.html">QStyleFactory</a>.</p>
<p>The string must be one of the <a href="qstylefactory.html#keys">QStyleFactory.keys</a>(), typically one
of "windows", "motif", "cde", "plastique", "windowsxp", or
"macintosh". Style names are case insensitive.</p>
<p>Returns 0 if an unknown <i>style</i> is passed, otherwise the
<a href="qstyle.html">QStyle</a> object returned is set as the
application's GUI style.</p>
<p><b>Warning:</b> To ensure that the application's style is set
correctly, it is best to call this function before the <a href="qapplication.html">QApplication</a> constructor, if possible.</p>
<h3 class="fn"><a name="setStyleSheet" />QApplication.setStyleSheet (<i>self</i>, QString <i>sheet</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setStyleSheet(const QString&)</tt>.</p><h3 class="fn"><a name="setWheelScrollLines" />QApplication.setWheelScrollLines (int)</h3><h3 class="fn"><a name="setWindowIcon" />QApplication.setWindowIcon (<a href="qicon.html">QIcon</a> <i>icon</i>)</h3><h3 class="fn"><a name="startDragDistance" />int QApplication.startDragDistance ()</h3><h3 class="fn"><a name="startDragTime" />int QApplication.startDragTime ()</h3><h3 class="fn"><a name="style" /><a href="qstyle.html">QStyle</a> QApplication.style ()</h3><p>Returns the application's style object.</p>
<p><b>See also</b> <a href="qapplication.html#setStyle">setStyle</a>() and <a href="qstyle.html">QStyle</a>.</p>
<h3 class="fn"><a name="styleSheet" />QString QApplication.styleSheet (<i>self</i>)</h3><h3 class="fn"><a name="syncX" />QApplication.syncX ()</h3><p>Synchronizes with the X server in the X11 implementation. This
normally takes some time. Does nothing on other platforms.</p>
<h3 class="fn"><a name="topLevelAt" /><a href="qwidget.html">QWidget</a> QApplication.topLevelAt (<a href="qpoint.html">QPoint</a> <i>p</i>)</h3><p>Returns the top-level widget at the given <i>point</i>; returns
0 if there is no such widget.</p>
<h3 class="fn"><a name="topLevelAt-2" /><a href="qwidget.html">QWidget</a> QApplication.topLevelAt (int <i>x</i>, int <i>y</i>)</h3><p>This is an overloaded function.</p>
<p>Returns the top-level widget at the point (<i>x</i>, <i>y</i>);
returns 0 if there is no such widget.</p>
<h3 class="fn"><a name="topLevelWidgets" />list-of-QWidget QApplication.topLevelWidgets ()</h3><p>Returns a list of the top-level widgets (windows) in the
application.</p>
<p><b>Note:</b> Some of the top-level widgets may be hidden, for
example a tooltip if no tooltip is currently shown.</p>
<p>Example:</p>
<pre class="cpp">
<span class="type">void</span> showAllHiddenTopLevelWidgets()
{
foreach (<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>widget<span class="operator">,</span> <span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">.</span>topLevelWidgets()) {
<span class="keyword">if</span> (widget<span class="operator">-</span><span class="operator">></span>isHidden())
widget<span class="operator">-</span><span class="operator">></span>show();
}
}
</pre>
<p><b>See also</b> <a href="qapplication.html#allWidgets">allWidgets</a>(), <a href="qwidget.html#isWindow">QWidget.isWindow</a>(), and <a href="qwidget.html#isHidden">QWidget.isHidden</a>().</p>
<h3 class="fn"><a name="type" /><a href="qapplication.html#Type-enum">Type</a> QApplication.type ()</h3><p>Returns the type of application (<a href="qapplication.html#Type-enum">Tty</a>, <a href="qapplication.html#Type-enum">GuiClient</a>, or <a href="qapplication.html#Type-enum">GuiServer</a>). The type is set when
constructing the <a href="qapplication.html">QApplication</a>
object.</p>
<h3 class="fn"><a name="wheelScrollLines" />int QApplication.wheelScrollLines ()</h3><h3 class="fn"><a name="widgetAt" /><a href="qwidget.html">QWidget</a> QApplication.widgetAt (<a href="qpoint.html">QPoint</a> <i>p</i>)</h3><p>Returns the widget at global screen position <i>point</i>, or 0
if there is no Qt widget there.</p>
<p>This function can be slow.</p>
<p><b>See also</b> <a href="qcursor.html#pos">QCursor.pos</a>(),
<a href="qwidget.html#grabMouse">QWidget.grabMouse</a>(), and
<a href="qwidget.html#grabKeyboard">QWidget.grabKeyboard</a>().</p>
<h3 class="fn"><a name="widgetAt-2" /><a href="qwidget.html">QWidget</a> QApplication.widgetAt (int <i>x</i>, int <i>y</i>)</h3><h3 class="fn"><a name="windowIcon" /><a href="qicon.html">QIcon</a> QApplication.windowIcon ()</h3><h3 class="fn"><a name="x11EventFilter" />bool QApplication.x11EventFilter (<i>self</i>, sip.voidptr)</h3><p><b>Warning:</b> This virtual function is only implemented under
X11.</p>
<p>If you create an application that inherits <a href="qapplication.html">QApplication</a> and reimplement this function,
you get direct access to all X events that the are received from
the X server. The events are passed in the <i>event</i>
parameter.</p>
<p>Return true if you want to stop the event from being processed.
Return false for normal event dispatching. The default
implementation returns false.</p>
<p>It is only the directly addressed messages that are filtered.
You must install an event filter directly on the event dispatcher,
which is returned by <a href="qabstracteventdispatcher.html#instance">QAbstractEventDispatcher.instance</a>(),
to handle system wide messages.</p>
<p><b>See also</b> <a href="qapplication.html#x11ProcessEvent">x11ProcessEvent</a>().</p>
<h3 class="fn"><a name="x11ProcessEvent" />int QApplication.x11ProcessEvent (<i>self</i>, sip.voidptr)</h3><p>This function does the core processing of individual X
<i>event</i>s, normally by dispatching Qt events to the right
destination.</p>
<p>It returns 1 if the event was consumed by special handling, 0 if
the <i>event</i> was consumed by normal handling, and -1 if the
<i>event</i> was for an unrecognized widget.</p>
<p><b>See also</b> <a href="qapplication.html#x11EventFilter">x11EventFilter</a>().</p>
<hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="commitDataRequest" />void commitDataRequest (QSessionManager&)</h3><p>This is the default overload of this signal.</p><p>This signal deals with <a href="session.html">session
management</a>. It is emitted when the <a href="qsessionmanager.html">QSessionManager</a> wants the application to
commit all its data.</p>
<p>Usually this means saving all open files, after getting
permission from the user. Furthermore you may want to provide a
means by which the user can cancel the shutdown.</p>
<p>You should not exit the application within this signal. Instead,
the session manager may or may not do this afterwards, depending on
the context.</p>
<p><b>Warning:</b> Within this signal, no user interaction is
possible, <i>unless</i> you ask the <i>manager</i> for explicit
permission. See <a href="qsessionmanager.html#allowsInteraction">QSessionManager.allowsInteraction</a>()
and <a href="qsessionmanager.html#allowsErrorInteraction">QSessionManager.allowsErrorInteraction</a>()
for details and example usage.</p>
<p><b>Note:</b> You should use <a href="qt.html#ConnectionType-enum">Qt.DirectConnection</a> when
connecting to this signal.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qapplication.html#isSessionRestored">isSessionRestored</a>(),
<a href="qapplication.html#sessionId">sessionId</a>(), <a href="qapplication.html#saveState">saveState</a>(), and <a href="session.html">Session Management</a>.</p>
<h3 class="fn"><a name="focusChanged" />void focusChanged (QWidget *,QWidget *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the widget that has keyboard focus
changed from <i>old</i> to <i>now</i>, i.e., because the user
pressed the tab-key, clicked into a widget or changed the active
window. Both <i>old</i> and <i>now</i> can be the null-pointer.</p>
<p>The signal is emitted after both widget have been notified about
the change through <a href="qfocusevent.html">QFocusEvent</a>.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also</b> <a href="qwidget.html#setFocus">QWidget.setFocus</a>(), <a href="qwidget.html#clearFocus">QWidget.clearFocus</a>(), and <a href="qt.html#FocusReason-enum">Qt.FocusReason</a>.</p>
<h3 class="fn"><a name="fontDatabaseChanged" />void fontDatabaseChanged ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when application fonts are loaded or
removed.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also</b> <a href="qfontdatabase.html#addApplicationFont">QFontDatabase.addApplicationFont</a>(),
<a href="qfontdatabase.html#addApplicationFontFromData">QFontDatabase.addApplicationFontFromData</a>(),
<a href="qfontdatabase.html#removeAllApplicationFonts">QFontDatabase.removeAllApplicationFonts</a>(),
and <a href="qfontdatabase.html#removeApplicationFont">QFontDatabase.removeApplicationFont</a>().</p>
<h3 class="fn"><a name="lastWindowClosed" />void lastWindowClosed ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted from <a href="qapplication.html#exec">QApplication.exec</a>() when the last
visible primary window (i.e. window with no parent) with the
<a href="qt.html#WidgetAttribute-enum">Qt.WA_QuitOnClose</a>
attribute set is closed.</p>
<p>By default,</p>
<ul>
<li>this attribute is set for all widgets except transient windows
such as splash screens, tool windows, and popup menus</li>
<li><a href="qapplication.html">QApplication</a> implicitly quits
when this signal is emitted.</li>
</ul>
<p>This feature can be turned off by setting <a href="qapplication.html#quitOnLastWindowClosed-prop">quitOnLastWindowClosed</a>
to false.</p>
<p><b>See also</b> <a href="qwidget.html#close">QWidget.close</a>().</p>
<h3 class="fn"><a name="saveStateRequest" />void saveStateRequest (QSessionManager&)</h3><p>This is the default overload of this signal.</p><p>This signal deals with <a href="session.html">session
management</a>. It is invoked when the <a href="qsessionmanager.html">session manager</a> wants the application to
preserve its state for a future session.</p>
<p>For example, a text editor would create a temporary file that
includes the current contents of its edit buffers, the location of
the cursor and other aspects of the current editing session.</p>
<p>You should never exit the application within this signal.
Instead, the session manager may or may not do this afterwards,
depending on the context. Futhermore, most session managers will
very likely request a saved state immediately after the application
has been started. This permits the session manager to learn about
the application's restart policy.</p>
<p><b>Warning:</b> Within this function, no user interaction is
possible, <i>unless</i> you ask the <i>manager</i> for explicit
permission. See <a href="qsessionmanager.html#allowsInteraction">QSessionManager.allowsInteraction</a>()
and <a href="qsessionmanager.html#allowsErrorInteraction">QSessionManager.allowsErrorInteraction</a>()
for details.</p>
<p><b>Note:</b> You should use <a href="qt.html#ConnectionType-enum">Qt.DirectConnection</a> when
connecting to this signal.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qapplication.html#isSessionRestored">isSessionRestored</a>(),
<a href="qapplication.html#sessionId">sessionId</a>(), <a href="qapplication.html#commitData">commitData</a>(), and <a href="session.html">Session Management</a>.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.9.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.2</td></tr></table></div></address></body></html>
|