~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qapplication.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qapplication.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QApplication Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QApplication Class Reference</h1>
 
21
<p>The QApplication class manages the GUI application's control flow and main settings. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QApplication&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<p>Inherits <a href="qcoreapplication.html">QCoreApplication</a>.</p>
 
24
<ul>
 
25
<li><a href="qapplication-members.html">List of all members, including inherited members</a></li>
 
26
<li><a href="qapplication-qt3.html">Qt 3 support members</a></li>
 
27
</ul>
 
28
<a name="public-types"></a>
 
29
<h3>Public Types</h3>
 
30
<ul>
 
31
<li><div class="fn"/>enum <b><a href="qapplication.html#ColorSpec-enum">ColorSpec</a></b> { NormalColor, CustomColor, ManyColor }</li>
 
32
<li><div class="fn"/>enum <b><a href="qapplication.html#Type-enum">Type</a></b> { Tty, GuiClient, GuiServer }</li>
 
33
</ul>
 
34
<a name="properties"></a>
 
35
<h3>Properties</h3>
 
36
<table width="100%" border="0" cellpadding="0" cellspacing="0">
 
37
<tr><td width="45%" valign="top"><ul>
 
38
<li><div class="fn"/><b><a href="qapplication.html#cursorFlashTime-prop">cursorFlashTime</a></b> : int</li>
 
39
<li><div class="fn"/><b><a href="qapplication.html#doubleClickInterval-prop">doubleClickInterval</a></b> : int</li>
 
40
<li><div class="fn"/><b><a href="qapplication.html#globalStrut-prop">globalStrut</a></b> : QSize</li>
 
41
<li><div class="fn"/><b><a href="qapplication.html#keyboardInputInterval-prop">keyboardInputInterval</a></b> : int</li>
 
42
<li><div class="fn"/><b><a href="qapplication.html#layoutDirection-prop">layoutDirection</a></b> : Qt::LayoutDirection</li>
 
43
</ul></td><td valign="top"><ul>
 
44
<li><div class="fn"/><b><a href="qapplication.html#quitOnLastWindowClosed-prop">quitOnLastWindowClosed</a></b> : bool</li>
 
45
<li><div class="fn"/><b><a href="qapplication.html#startDragDistance-prop">startDragDistance</a></b> : int</li>
 
46
<li><div class="fn"/><b><a href="qapplication.html#startDragTime-prop">startDragTime</a></b> : int</li>
 
47
<li><div class="fn"/><b><a href="qapplication.html#wheelScrollLines-prop">wheelScrollLines</a></b> : int</li>
 
48
<li><div class="fn"/><b><a href="qapplication.html#windowIcon-prop">windowIcon</a></b> : QIcon</li>
 
49
</ul>
 
50
</td></tr>
 
51
</table>
 
52
<ul>
 
53
<li><div class="fn"/>3 properties inherited from <a href="qcoreapplication.html#properties">QCoreApplication</a></li>
 
54
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
55
</ul>
 
56
<a name="public-functions"></a>
 
57
<h3>Public Functions</h3>
 
58
<ul>
 
59
<li><div class="fn"/><b><a href="qapplication.html#QApplication">QApplication</a></b> ( int &amp; <i>argc</i>, char ** <i>argv</i> )</li>
 
60
<li><div class="fn"/><b><a href="qapplication.html#QApplication-2">QApplication</a></b> ( int &amp; <i>argc</i>, char ** <i>argv</i>, bool <i>GUIenabled</i> )</li>
 
61
<li><div class="fn"/><b><a href="qapplication.html#QApplication-3">QApplication</a></b> ( int &amp; <i>argc</i>, char ** <i>argv</i>, Type <i>type</i> )</li>
 
62
<li><div class="fn"/><b><a href="qapplication.html#QApplication-4">QApplication</a></b> ( Display * <i>dpy</i>, Qt::HANDLE <i>visual</i> = 0, Qt::HANDLE <i>colormap</i> = 0 )</li>
 
63
<li><div class="fn"/><b><a href="qapplication.html#QApplication-5">QApplication</a></b> ( Display * <i>dpy</i>, int &amp; <i>argc</i>, char ** <i>argv</i>, Qt::HANDLE <i>visual</i> = 0, Qt::HANDLE <i>colormap</i> = 0 )</li>
 
64
<li><div class="fn"/>virtual <b><a href="qapplication.html#dtor.QApplication">~QApplication</a></b> ()</li>
 
65
<li><div class="fn"/>virtual void <b><a href="qapplication.html#commitData">commitData</a></b> ( QSessionManager &amp; <i>manager</i> )</li>
 
66
<li><div class="fn"/>QInputContext * <b><a href="qapplication.html#inputContext">inputContext</a></b> () const</li>
 
67
<li><div class="fn"/>bool <b><a href="qapplication.html#isSessionRestored">isSessionRestored</a></b> () const</li>
 
68
<li><div class="fn"/>virtual bool <b><a href="qapplication.html#macEventFilter">macEventFilter</a></b> ( EventHandlerCallRef <i>caller</i>, EventRef <i>event</i> )</li>
 
69
<li><div class="fn"/>virtual bool <b><a href="qapplication.html#qwsEventFilter">qwsEventFilter</a></b> ( QWSEvent * <i>event</i> )</li>
 
70
<li><div class="fn"/>void <b><a href="qapplication.html#qwsSetCustomColors">qwsSetCustomColors</a></b> ( QRgb * <i>colorTable</i>, int <i>start</i>, int <i>numColors</i> )</li>
 
71
<li><div class="fn"/>virtual void <b><a href="qapplication.html#saveState">saveState</a></b> ( QSessionManager &amp; <i>manager</i> )</li>
 
72
<li><div class="fn"/>QString <b><a href="qapplication.html#sessionId">sessionId</a></b> () const</li>
 
73
<li><div class="fn"/>QString <b><a href="qapplication.html#sessionKey">sessionKey</a></b> () const</li>
 
74
<li><div class="fn"/>void <b><a href="qapplication.html#setInputContext">setInputContext</a></b> ( QInputContext * <i>inputContext</i> )</li>
 
75
<li><div class="fn"/>void <b><a href="qapplication.html#winFocus">winFocus</a></b> ( QWidget * <i>widget</i>, bool <i>gotFocus</i> )</li>
 
76
<li><div class="fn"/>virtual bool <b><a href="qapplication.html#x11EventFilter">x11EventFilter</a></b> ( XEvent * <i>event</i> )</li>
 
77
<li><div class="fn"/>int <b><a href="qapplication.html#x11ProcessEvent">x11ProcessEvent</a></b> ( XEvent * <i>event</i> )</li>
 
78
</ul>
 
79
<ul>
 
80
<li><div class="fn"/>4 public functions inherited from <a href="qcoreapplication.html#public-functions">QCoreApplication</a></li>
 
81
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
82
</ul>
 
83
<a name="public-slots"></a>
 
84
<h3>Public Slots</h3>
 
85
<ul>
 
86
<li><div class="fn"/>void <b><a href="qapplication.html#aboutQt">aboutQt</a></b> ()</li>
 
87
<li><div class="fn"/>void <b><a href="qapplication.html#closeAllWindows">closeAllWindows</a></b> ()</li>
 
88
</ul>
 
89
<ul>
 
90
<li><div class="fn"/>1 public slot inherited from <a href="qcoreapplication.html#public-slots">QCoreApplication</a></li>
 
91
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
92
</ul>
 
93
<a name="signals"></a>
 
94
<h3>Signals</h3>
 
95
<ul>
 
96
<li><div class="fn"/>void <b><a href="qapplication.html#lastWindowClosed">lastWindowClosed</a></b> ()</li>
 
97
</ul>
 
98
<ul>
 
99
<li><div class="fn"/>2 signals inherited from <a href="qcoreapplication.html#signals">QCoreApplication</a></li>
 
100
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
101
</ul>
 
102
<a name="static-public-members"></a>
 
103
<h3>Static Public Members</h3>
 
104
<ul>
 
105
<li><div class="fn"/>QWidget * <b><a href="qapplication.html#activeModalWidget">activeModalWidget</a></b> ()</li>
 
106
<li><div class="fn"/>QWidget * <b><a href="qapplication.html#activePopupWidget">activePopupWidget</a></b> ()</li>
 
107
<li><div class="fn"/>QWidget * <b><a href="qapplication.html#activeWindow">activeWindow</a></b> ()</li>
 
108
<li><div class="fn"/>QWidgetList <b><a href="qapplication.html#allWidgets">allWidgets</a></b> ()</li>
 
109
<li><div class="fn"/>void <b><a href="qapplication.html#beep">beep</a></b> ()</li>
 
110
<li><div class="fn"/>void <b><a href="qapplication.html#changeOverrideCursor">changeOverrideCursor</a></b> ( const QCursor &amp; <i>cursor</i> )</li>
 
111
<li><div class="fn"/>QClipboard * <b><a href="qapplication.html#clipboard">clipboard</a></b> ()</li>
 
112
<li><div class="fn"/>int <b><a href="qapplication.html#colorSpec">colorSpec</a></b> ()</li>
 
113
<li><div class="fn"/>int <b><a href="qapplication.html#cursorFlashTime-prop">cursorFlashTime</a></b> ()</li>
 
114
<li><div class="fn"/>QDesktopWidget * <b><a href="qapplication.html#desktop">desktop</a></b> ()</li>
 
115
<li><div class="fn"/>bool <b><a href="qapplication.html#desktopSettingsAware">desktopSettingsAware</a></b> ()</li>
 
116
<li><div class="fn"/>int <b><a href="qapplication.html#doubleClickInterval-prop">doubleClickInterval</a></b> ()</li>
 
117
<li><div class="fn"/>int <b><a href="qapplication.html#exec">exec</a></b> ()</li>
 
118
<li><div class="fn"/>QWidget * <b><a href="qapplication.html#focusWidget">focusWidget</a></b> ()</li>
 
119
<li><div class="fn"/>QFont <b><a href="qapplication.html#font">font</a></b> ( const QWidget * <i>w</i> = 0 )</li>
 
120
<li><div class="fn"/>QFontMetrics <b><a href="qapplication.html#fontMetrics">fontMetrics</a></b> ()</li>
 
121
<li><div class="fn"/>QSize <b><a href="qapplication.html#globalStrut-prop">globalStrut</a></b> ()</li>
 
122
<li><div class="fn"/>bool <b><a href="qapplication.html#isEffectEnabled">isEffectEnabled</a></b> ( Qt::UIEffect <i>effect</i> )</li>
 
123
<li><div class="fn"/>bool <b><a href="qapplication.html#isLeftToRight">isLeftToRight</a></b> ()</li>
 
124
<li><div class="fn"/>bool <b><a href="qapplication.html#isRightToLeft">isRightToLeft</a></b> ()</li>
 
125
<li><div class="fn"/>int <b><a href="qapplication.html#keyboardInputInterval-prop">keyboardInputInterval</a></b> ()</li>
 
126
<li><div class="fn"/>Qt::KeyboardModifiers <b><a href="qapplication.html#keyboardModifiers">keyboardModifiers</a></b> ()</li>
 
127
<li><div class="fn"/>Qt::LayoutDirection <b><a href="qapplication.html#layoutDirection-prop">layoutDirection</a></b> ()</li>
 
128
<li><div class="fn"/>Qt::MouseButtons <b><a href="qapplication.html#mouseButtons">mouseButtons</a></b> ()</li>
 
129
<li><div class="fn"/>QCursor * <b><a href="qapplication.html#overrideCursor">overrideCursor</a></b> ()</li>
 
130
<li><div class="fn"/>QPalette <b><a href="qapplication.html#palette">palette</a></b> ()</li>
 
131
<li><div class="fn"/>QPalette <b><a href="qapplication.html#palette-2">palette</a></b> ( const QWidget * <i>w</i> )</li>
 
132
<li><div class="fn"/>QPalette <b><a href="qapplication.html#palette-3">palette</a></b> ( const char * <i>className</i> )</li>
 
133
<li><div class="fn"/>bool <b><a href="qapplication.html#quitOnLastWindowClosed-prop">quitOnLastWindowClosed</a></b> ()</li>
 
134
<li><div class="fn"/>QDecoration &amp; <b><a href="qapplication.html#qwsDecoration">qwsDecoration</a></b> ()</li>
 
135
<li><div class="fn"/>void <b><a href="qapplication.html#qwsSetDecoration">qwsSetDecoration</a></b> ( QDecoration * <i>dec</i> )</li>
 
136
<li><div class="fn"/>QDecoration * <b><a href="qapplication.html#qwsSetDecoration-2">qwsSetDecoration</a></b> ( const QString &amp; <i>decoration</i> )</li>
 
137
<li><div class="fn"/>void <b><a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a></b> ()</li>
 
138
<li><div class="fn"/>void <b><a href="qapplication.html#setActiveWindow">setActiveWindow</a></b> ( QWidget * <i>act</i> )</li>
 
139
<li><div class="fn"/>void <b><a href="qapplication.html#setColorSpec">setColorSpec</a></b> ( int <i>spec</i> )</li>
 
140
<li><div class="fn"/>void <b><a href="qapplication.html#cursorFlashTime-prop">setCursorFlashTime</a></b> ( int )</li>
 
141
<li><div class="fn"/>void <b><a href="qapplication.html#setDesktopSettingsAware">setDesktopSettingsAware</a></b> ( bool <i>on</i> )</li>
 
142
<li><div class="fn"/>void <b><a href="qapplication.html#doubleClickInterval-prop">setDoubleClickInterval</a></b> ( int )</li>
 
143
<li><div class="fn"/>void <b><a href="qapplication.html#setEffectEnabled">setEffectEnabled</a></b> ( Qt::UIEffect <i>effect</i>, bool <i>enable</i> = true )</li>
 
144
<li><div class="fn"/>void <b><a href="qapplication.html#setFont">setFont</a></b> ( const QFont &amp; <i>font</i>, const char * <i>className</i> = 0 )</li>
 
145
<li><div class="fn"/>void <b><a href="qapplication.html#globalStrut-prop">setGlobalStrut</a></b> ( const QSize &amp; )</li>
 
146
<li><div class="fn"/>void <b><a href="qapplication.html#keyboardInputInterval-prop">setKeyboardInputInterval</a></b> ( int )</li>
 
147
<li><div class="fn"/>void <b><a href="qapplication.html#layoutDirection-prop">setLayoutDirection</a></b> ( Qt::LayoutDirection <i>direction</i> )</li>
 
148
<li><div class="fn"/>void <b><a href="qapplication.html#setOverrideCursor">setOverrideCursor</a></b> ( const QCursor &amp; <i>cursor</i> )</li>
 
149
<li><div class="fn"/>void <b><a href="qapplication.html#setPalette">setPalette</a></b> ( const QPalette &amp; <i>palette</i>, const char * <i>className</i> = 0 )</li>
 
150
<li><div class="fn"/>void <b><a href="qapplication.html#quitOnLastWindowClosed-prop">setQuitOnLastWindowClosed</a></b> ( bool <i>quit</i> )</li>
 
151
<li><div class="fn"/>void <b><a href="qapplication.html#startDragDistance-prop">setStartDragDistance</a></b> ( int <i>l</i> )</li>
 
152
<li><div class="fn"/>void <b><a href="qapplication.html#startDragTime-prop">setStartDragTime</a></b> ( int <i>ms</i> )</li>
 
153
<li><div class="fn"/>void <b><a href="qapplication.html#setStyle">setStyle</a></b> ( QStyle * <i>style</i> )</li>
 
154
<li><div class="fn"/>QStyle * <b><a href="qapplication.html#setStyle-2">setStyle</a></b> ( const QString &amp; <i>style</i> )</li>
 
155
<li><div class="fn"/>void <b><a href="qapplication.html#wheelScrollLines-prop">setWheelScrollLines</a></b> ( int )</li>
 
156
<li><div class="fn"/>void <b><a href="qapplication.html#windowIcon-prop">setWindowIcon</a></b> ( const QIcon &amp; <i>icon</i> )</li>
 
157
<li><div class="fn"/>int <b><a href="qapplication.html#startDragDistance-prop">startDragDistance</a></b> ()</li>
 
158
<li><div class="fn"/>int <b><a href="qapplication.html#startDragTime-prop">startDragTime</a></b> ()</li>
 
159
<li><div class="fn"/>QStyle * <b><a href="qapplication.html#style">style</a></b> ()</li>
 
160
<li><div class="fn"/>void <b><a href="qapplication.html#syncX">syncX</a></b> ()</li>
 
161
<li><div class="fn"/>QWidget * <b><a href="qapplication.html#topLevelAt">topLevelAt</a></b> ( const QPoint &amp; <i>p</i> )</li>
 
162
<li><div class="fn"/>QWidget * <b><a href="qapplication.html#topLevelAt-2">topLevelAt</a></b> ( int <i>x</i>, int <i>y</i> )</li>
 
163
<li><div class="fn"/>QWidgetList <b><a href="qapplication.html#topLevelWidgets">topLevelWidgets</a></b> ()</li>
 
164
<li><div class="fn"/>Type <b><a href="qapplication.html#type">type</a></b> ()</li>
 
165
<li><div class="fn"/>int <b><a href="qapplication.html#wheelScrollLines-prop">wheelScrollLines</a></b> ()</li>
 
166
<li><div class="fn"/>QWidget * <b><a href="qapplication.html#widgetAt">widgetAt</a></b> ( const QPoint &amp; <i>p</i> )</li>
 
167
<li><div class="fn"/>QWidget * <b><a href="qapplication.html#widgetAt-4">widgetAt</a></b> ( int <i>x</i>, int <i>y</i> )</li>
 
168
<li><div class="fn"/>QIcon <b><a href="qapplication.html#windowIcon-prop">windowIcon</a></b> ()</li>
 
169
</ul>
 
170
<ul>
 
171
<li><div class="fn"/>31 static public members inherited from <a href="qcoreapplication.html#static-public-members">QCoreApplication</a></li>
 
172
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
173
</ul>
 
174
<h3>Additional Inherited Members</h3>
 
175
<ul>
 
176
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
177
</ul>
 
178
<a name="details"></a>
 
179
<hr />
 
180
<h2>Detailed Description</h2>
 
181
<p>The QApplication class manages the GUI application's control flow and main settings.</p>
 
182
<p>It 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 and finalization, and provides session management. It also handles most system-wide and application-wide settings.</p>
 
183
<p>For any GUI application that uses Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any time. For non-GUI Qt applications, use <a href="qcoreapplication.html">QCoreApplication</a> instead, which doesn't depend on the <a href="qtgui.html#qtgui">QtGui</a> library.</p>
 
184
<p>The QApplication object is accessible through the <a href="qcoreapplication.html#instance">instance</a>() function. (In earlier Qt versions the qApp global was used instead of <a href="qcoreapplication.html#instance">instance</a>().)</p>
 
185
<p>QApplication's main areas of responsibility are:</p>
 
186
<ul>
 
187
<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>
 
188
<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>
 
189
<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 about this.</li>
 
190
<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>
 
191
<li>It specifies how the application is to allocate colors. See <a href="qapplication.html#setColorSpec">setColorSpec</a>() for details.</li>
 
192
<li>It provides localization of strings that are visible to the user via <a href="qcoreapplication.html#translate">translate</a>().</li>
 
193
<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>
 
194
<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>
 
195
<li>It manages the application's mouse cursor handling, see <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>()</li>
 
196
<li>On the X window system, it provides functions to flush and sync the communication stream, see <a href="qapplication-qt3.html#flushX">flushX</a>() and <a href="qapplication.html#syncX">syncX</a>().</li>
 
197
<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>
 
198
</ul>
 
199
<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.</p>
 
200
<p>Since it also deals with common command line arguments, 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>
 
201
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
202
<tr valign="top" bgcolor="#a2c511"><th colspan="2">Groups of functions</th></tr>
 
203
<tr valign="top" bgcolor="#f0f0f0"><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>
 
204
<tr valign="top" bgcolor="#e0e0e0"><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>
 
205
<tr valign="top" bgcolor="#f0f0f0"><td>GUI Styles</td><td><a href="qapplication.html#style">style</a>(), <a href="qapplication.html#setStyle">setStyle</a>().</td></tr>
 
206
<tr valign="top" bgcolor="#e0e0e0"><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>
 
207
<tr valign="top" bgcolor="#f0f0f0"><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>
 
208
<tr valign="top" bgcolor="#e0e0e0"><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#winFocus">winFocus</a>(), <a href="qapplication.html#activeWindow">activeWindow</a>(), <a href="qapplication.html#widgetAt">widgetAt</a>().</td></tr>
 
209
<tr valign="top" bgcolor="#f0f0f0"><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>
 
210
<tr valign="top" bgcolor="#e0e0e0"><td>X Window System synchronization</td><td><a href="qapplication-qt3.html#flushX">flushX</a>(), <a href="qapplication.html#syncX">syncX</a>().</td></tr>
 
211
<tr valign="top" bgcolor="#f0f0f0"><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>
 
212
<tr valign="top" bgcolor="#e0e0e0"><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>
 
213
</table>
 
214
<p>See also <a href="qcoreapplication.html">QCoreApplication</a>, <a href="qabstracteventdispatcher.html">QAbstractEventDispatcher</a>, <a href="qeventloop.html">QEventLoop</a>, and <a href="qsettings.html">QSettings</a>.</p>
 
215
<hr />
 
216
<h2>Member Type Documentation</h2>
 
217
<h3 class="fn"><a name="ColorSpec-enum"></a>enum QApplication::ColorSpec</h3>
 
218
<table border="1" cellpadding="2" cellspacing="1" width="100%">
 
219
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
 
220
<tr><td valign="top"><tt>QApplication::NormalColor</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">the default color allocation policy</td></tr>
 
221
<tr><td valign="top"><tt>QApplication::CustomColor</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">the same as NormalColor for <a href="winsystem.html#x11">X11</a>; allocates colors to a palette on demand under Windows</td></tr>
 
222
<tr><td valign="top"><tt>QApplication::ManyColor</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">the right choice for applications that use thousands of colors</td></tr>
 
223
</table>
 
224
<p>See <a href="qapplication.html#setColorSpec">setColorSpec</a>() for full details.</p>
 
225
<h3 class="fn"><a name="Type-enum"></a>enum QApplication::Type</h3>
 
226
<table border="1" cellpadding="2" cellspacing="1" width="100%">
 
227
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
 
228
<tr><td valign="top"><tt>QApplication::Tty</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">a console application</td></tr>
 
229
<tr><td valign="top"><tt>QApplication::GuiClient</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">a GUI client application</td></tr>
 
230
<tr><td valign="top"><tt>QApplication::GuiServer</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">a GUI server application (on Qt/Embedded)</td></tr>
 
231
</table>
 
232
<hr />
 
233
<h2>Property Documentation</h2>
 
234
<h3 class="fn"><a name="cursorFlashTime-prop"></a>cursorFlashTime : int</h3>
 
235
<p>This property holds the text cursor's flash (blink) time in milliseconds.</p>
 
236
<p>The flash time is the time required to display, invert and restore the caret display. Usually the text cursor is displayed for half the cursor flash time, then hidden for the same amount of time, but this may vary.</p>
 
237
<p>The default value on <a href="winsystem.html#x11">X11</a> is 1000 milliseconds. On Windows, the control panel value is used. Widgets should not cache this value since it may be changed at any time by the user changing the global desktop settings.</p>
 
238
<p>Note that on Microsoft Windows, setting this property sets the cursor flash time for all applications.</p>
 
239
<p>Access functions:</p>
 
240
<ul>
 
241
<li><div class="fn"/><b>int cursorFlashTime ()</b></li>
 
242
<li><div class="fn"/><b>void setCursorFlashTime ( int )</b></li>
 
243
</ul>
 
244
<h3 class="fn"><a name="doubleClickInterval-prop"></a>doubleClickInterval : int</h3>
 
245
<p>This property holds the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks.</p>
 
246
<p>The default value on <a href="winsystem.html#x11">X11</a> is 400 milliseconds. On Windows and Mac OS X, the operating system's value is used.</p>
 
247
<p>On Microsoft Windows, calling this function sets the double click interval for all applications.</p>
 
248
<p>Access functions:</p>
 
249
<ul>
 
250
<li><div class="fn"/><b>int doubleClickInterval ()</b></li>
 
251
<li><div class="fn"/><b>void setDoubleClickInterval ( int )</b></li>
 
252
</ul>
 
253
<h3 class="fn"><a name="globalStrut-prop"></a>globalStrut : <a href="qsize.html">QSize</a></h3>
 
254
<p>This property holds the minimum size that any GUI element that the user can interact with should have.</p>
 
255
<p>For example no button should be resized to be smaller than the global strut size. The strut size should be considered when reimplementing GUI controls that may be used on touch-screens or similar I/O devices.</p>
 
256
<p>Example:</p>
 
257
<pre>&nbsp;   QSize MyWidget::sizeHint() const
 
258
    {
 
259
        return QSize(80, 25).expandedTo(QApplication::globalStrut());
 
260
    }</pre>
 
261
<p>Access functions:</p>
 
262
<ul>
 
263
<li><div class="fn"/><b>QSize globalStrut ()</b></li>
 
264
<li><div class="fn"/><b>void setGlobalStrut ( const QSize &amp; )</b></li>
 
265
</ul>
 
266
<h3 class="fn"><a name="keyboardInputInterval-prop"></a>keyboardInputInterval : int</h3>
 
267
<p>This property holds the time limit in milliseconds that distinguishes a key press from two consecutive key presses.</p>
 
268
<p>The default value on <a href="winsystem.html#x11">X11</a> is 400 milliseconds. On Windows and Mac OS X, the operating system's value is used.</p>
 
269
<p>Access functions:</p>
 
270
<ul>
 
271
<li><div class="fn"/><b>int keyboardInputInterval ()</b></li>
 
272
<li><div class="fn"/><b>void setKeyboardInputInterval ( int )</b></li>
 
273
</ul>
 
274
<h3 class="fn"><a name="layoutDirection-prop"></a>layoutDirection : <a href="qt.html#LayoutDirection-enum">Qt::LayoutDirection</a></h3>
 
275
<p>This property holds the default layout direction for this application.</p>
 
276
<p>On system start-up, the default layout direction depends on the application's language.</p>
 
277
<p>Access functions:</p>
 
278
<ul>
 
279
<li><div class="fn"/><b>Qt::LayoutDirection layoutDirection ()</b></li>
 
280
<li><div class="fn"/><b>void setLayoutDirection ( Qt::LayoutDirection <i>direction</i> )</b></li>
 
281
</ul>
 
282
<p>See also <a href="qwidget.html#layoutDirection-prop">QWidget::layoutDirection</a>, <a href="qapplication.html#isLeftToRight">isLeftToRight</a>(), and <a href="qapplication.html#isRightToLeft">isRightToLeft</a>().</p>
 
283
<h3 class="fn"><a name="quitOnLastWindowClosed-prop"></a>quitOnLastWindowClosed : bool</h3>
 
284
<p>This property holds whether the application implicitly quits when the last window is closed.</p>
 
285
<p>The default is true.</p>
 
286
<p>Only top-level windows with the <a href="qt.html#WidgetAttribute-enum">Qt::WA_QuitOnClose</a> attribute set are taken into account. For convenience, this attribute is not set for transient top-level widgets such as splash screens, popup menus, and dialogs.</p>
 
287
<p>Access functions:</p>
 
288
<ul>
 
289
<li><div class="fn"/><b>bool quitOnLastWindowClosed ()</b></li>
 
290
<li><div class="fn"/><b>void setQuitOnLastWindowClosed ( bool <i>quit</i> )</b></li>
 
291
</ul>
 
292
<p>See also <a href="qcoreapplication.html#quit">quit</a>() and <a href="qwidget.html#close">QWidget::close</a>().</p>
 
293
<h3 class="fn"><a name="startDragDistance-prop"></a>startDragDistance : int</h3>
 
294
<p>If you support drag and drop in your application, and want to start a drag and drop operation after the user has moved the cursor a certain distance with a button held down, you should use this property's value as the minimum distance required.</p>
 
295
<p>For example, if the mouse position of the click is stored in <tt>startPos</tt> and the current position (e.g. in the mouse move event) is <tt>currentPos</tt>, you can find out if a drag should be started with code like this:</p>
 
296
<pre>&nbsp;   if ((startPos - currentPos).manhattanLength() &gt;=
 
297
            QApplication::startDragDistance())
 
298
        startTheDrag();</pre>
 
299
<p>Qt uses this value internally, e.g. in <a href="qfiledialog.html">QFileDialog</a>.</p>
 
300
<p>The default value is 4 pixels.</p>
 
301
<p>Access functions:</p>
 
302
<ul>
 
303
<li><div class="fn"/><b>int startDragDistance ()</b></li>
 
304
<li><div class="fn"/><b>void setStartDragDistance ( int <i>l</i> )</b></li>
 
305
</ul>
 
306
<p>See also <a href="qapplication.html#startDragTime-prop">startDragTime</a>(), <a href="qpoint.html#manhattanLength">QPoint::manhattanLength</a>(), and <a href="dnd.html">Drag and Drop</a>.</p>
 
307
<h3 class="fn"><a name="startDragTime-prop"></a>startDragTime : int</h3>
 
308
<p>This property holds the time in milliseconds that a mouse button must be held down before a drag and drop operation will begin.</p>
 
309
<p>If you support drag and drop in your application, and want to start a drag and drop operation after the user has held down a mouse button for a certain amount of time, you should use this property's value as the delay.</p>
 
310
<p>Qt also uses this delay internally, e.g. in <a href="qtextedit.html">QTextEdit</a> and <a href="qlineedit.html">QLineEdit</a>, for starting a drag.</p>
 
311
<p>The default value is 500 ms.</p>
 
312
<p>Access functions:</p>
 
313
<ul>
 
314
<li><div class="fn"/><b>int startDragTime ()</b></li>
 
315
<li><div class="fn"/><b>void setStartDragTime ( int <i>ms</i> )</b></li>
 
316
</ul>
 
317
<p>See also <a href="qapplication.html#startDragDistance-prop">startDragDistance</a>() and <a href="dnd.html">Drag and Drop</a>.</p>
 
318
<h3 class="fn"><a name="wheelScrollLines-prop"></a>wheelScrollLines : int</h3>
 
319
<p>This property holds the number of lines to scroll when the mouse wheel is rotated.</p>
 
320
<p>If this number exceeds the number of visible lines in a certain widget, the widget should interpret the scroll operation as a single &quot;page up&quot; or &quot;page down&quot; operation instead.</p>
 
321
<p>Access functions:</p>
 
322
<ul>
 
323
<li><div class="fn"/><b>int wheelScrollLines ()</b></li>
 
324
<li><div class="fn"/><b>void setWheelScrollLines ( int )</b></li>
 
325
</ul>
 
326
<h3 class="fn"><a name="windowIcon-prop"></a>windowIcon : <a href="qicon.html">QIcon</a></h3>
 
327
<p>This property holds the default window icon.</p>
 
328
<p>Access functions:</p>
 
329
<ul>
 
330
<li><div class="fn"/><b>QIcon windowIcon ()</b></li>
 
331
<li><div class="fn"/><b>void setWindowIcon ( const QIcon &amp; <i>icon</i> )</b></li>
 
332
</ul>
 
333
<p>See also <a href="qwidget.html#windowIcon-prop">QWidget::setWindowIcon</a>() and <a href="appicon.html">Setting the Application Icon</a>.</p>
 
334
<hr />
 
335
<h2>Member Function Documentation</h2>
 
336
<h3 class="fn"><a name="QApplication"></a>QApplication::QApplication ( int &amp; <i>argc</i>, char ** <i>argv</i> )</h3>
 
337
<p>Initializes the window system and constructs an application object with <i>argc</i> command line arguments in <i>argv</i>.</p>
 
338
<p>The global <tt>qApp</tt> pointer refers to this application object. Only one application object should be created.</p>
 
339
<p>This application object must be constructed before any <a href="qpaintdevice.html">paint devices</a> (including widgets, pixmaps, bitmaps etc.).</p>
 
340
<p>Note that <i>argc</i> and <i>argv</i> might be changed. Qt removes command line arguments that it recognizes. The original <i>argc</i> and <i>argv</i> can be accessed later with <tt>qApp-&gt;argc()</tt> and <tt>qApp-&gt;argv()</tt>. The documentation for <a href="qcoreapplication.html#argv">argv</a>() contains a detailed description of how to process command line arguments.</p>
 
341
<p>Qt debugging options (not available if Qt was compiled without the QT_DEBUG flag defined):</p>
 
342
<ul>
 
343
<li>-nograb, tells Qt that it must never grab the mouse or the keyboard.</li>
 
344
<li>-dograb (only under <a href="winsystem.html#x11">X11</a>), running under a debugger can cause an implicit -nograb, use -dograb to override.</li>
 
345
<li>-sync (only under <a href="winsystem.html#x11">X11</a>), switches to synchronous mode for debugging.</li>
 
346
</ul>
 
347
<p>See <a href="debug.html">Debugging Techniques</a> for a more detailed explanation.</p>
 
348
<p>All Qt programs automatically support the following command line options:</p>
 
349
<ul>
 
350
<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>
 
351
<li>-style <i>style</i>, is the same as listed above.</li>
 
352
<li>-session= <i>session</i>, restores the application from an earlier <a href="session.html">session</a>.</li>
 
353
<li>-session <i>session</i>, is the same as listed above.</li>
 
354
<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>
 
355
</ul>
 
356
<p>The <a href="winsystem.html#x11">X11</a> version of Qt also supports some traditional <a href="winsystem.html#x11">X11</a> command line options:</p>
 
357
<ul>
 
358
<li>-display <i>display</i>, sets the X display (default is $DISPLAY).</li>
 
359
<li>-geometry <i>geometry</i>, sets the client geometry of the first window that is shown.</li>
 
360
<li>-fn or <tt>-font</tt> <i>font</i>, defines the application font. The font should be specified using an X logical font description.</li>
 
361
<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>
 
362
<li>-fg or <tt>-foreground</tt> <i>color</i>, sets the default foreground color.</li>
 
363
<li>-btn or <tt>-button</tt> <i>color</i>, sets the default button color.</li>
 
364
<li>-name <i>name</i>, sets the application name.</li>
 
365
<li>-title <i>title</i>, sets the application title.</li>
 
366
<li>-visual <tt>TrueColor</tt>, forces the application to use a TrueColor visual on an 8-bit display.</li>
 
367
<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 <tt>QApplication::ManyColor</tt> 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>
 
368
<li>-cmap, causes the application to install a private color map on an 8-bit display.</li>
 
369
</ul>
 
370
<p>See also <a href="qcoreapplication.html#argc">argc</a>() and <a href="qcoreapplication.html#argv">argv</a>().</p>
 
371
<h3 class="fn"><a name="QApplication-2"></a>QApplication::QApplication ( int &amp; <i>argc</i>, char ** <i>argv</i>, bool <i>GUIenabled</i> )</h3>
 
372
<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>
 
373
<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>
 
374
<p>On <a href="winsystem.html#x11">X11</a>, 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 Macintosh, currently the window system is always initialized, regardless of the value of GUIenabled. This may change in future versions of Qt.</p>
 
375
<p>The following example shows how to create an application that uses a graphical interface when available.</p>
 
376
<pre>&nbsp;   int main(int argc, char **argv)
 
377
    {
 
378
    #ifdef Q_WS_X11
 
379
        bool useGUI = getenv(&quot;DISPLAY&quot;) != 0;
 
380
    #else
 
381
        bool useGUI = true;
 
382
    #endif
 
383
        QApplication app(argc, argv, useGUI);
 
384
 
 
385
        if (useGUI) {
 
386
           // start GUI version
 
387
           ...
 
388
        } else {
 
389
           // start non-GUI version
 
390
           ...
 
391
        }
 
392
        return app.exec();
 
393
    }</pre>
 
394
<h3 class="fn"><a name="QApplication-3"></a>QApplication::QApplication ( int &amp; <i>argc</i>, char ** <i>argv</i>, <a href="qapplication.html#Type-enum">Type</a> <i>type</i> )</h3>
 
395
<p>Constructs an application object with <i>argc</i> command line arguments in <i>argv</i>.</p>
 
396
<p>For Qt/Embedded, passing <tt>QApplication::GuiServer</tt> for <i>type</i> makes this application the server (equivalent to running with the -qws option).</p>
 
397
<h3 class="fn"><a name="QApplication-4"></a>QApplication::QApplication ( Display * <i>dpy</i>, <a href="qt.html#HANDLE-typedef">Qt::HANDLE</a> <i>visual</i> = 0, <a href="qt.html#HANDLE-typedef">Qt::HANDLE</a> <i>colormap</i> = 0 )</h3>
 
398
<p>Create an application, given an already open display <i>dpy</i>. If <i>visual</i> and <i>colormap</i> are non-zero, the application will use those as the default Visual and Colormap contexts.</p>
 
399
<p><b>Warning:</b> Qt only supports TrueColor visuals at depths higher than 8 bits-per-pixel.</p>
 
400
<p>This is available only on <a href="winsystem.html#x11">X11</a>.</p>
 
401
<h3 class="fn"><a name="QApplication-5"></a>QApplication::QApplication ( Display * <i>dpy</i>, int &amp; <i>argc</i>, char ** <i>argv</i>, <a href="qt.html#HANDLE-typedef">Qt::HANDLE</a> <i>visual</i> = 0, <a href="qt.html#HANDLE-typedef">Qt::HANDLE</a> <i>colormap</i> = 0 )</h3>
 
402
<p>Create an application, given an already open display <i>dpy</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 as the default Visual and Colormap contexts.</p>
 
403
<p><b>Warning:</b> Qt only supports TrueColor visuals at depths higher than 8 bits-per-pixel.</p>
 
404
<p>This is available only on <a href="winsystem.html#x11">X11</a>.</p>
 
405
<h3 class="fn"><a name="dtor.QApplication"></a>QApplication::~QApplication ()&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
406
<p>Cleans up any window system resources that were allocated by this application. Sets the global variable <tt>qApp</tt> to 0.</p>
 
407
<h3 class="fn"><a name="aboutQt"></a>void QApplication::aboutQt ()&nbsp;&nbsp;<tt> [static slot]</tt></h3>
 
408
<p>Displays a simple message box about Qt. The message includes the version number of Qt being used by the application.</p>
 
409
<p>This is useful for inclusion in the Help menu of an application. See the examples/menu/menu.cpp example.</p>
 
410
<p>This function is a convenience slot for <a href="qmessagebox.html#aboutQt">QMessageBox::aboutQt</a>().</p>
 
411
<h3 class="fn"><a name="activeModalWidget"></a><a href="qwidget.html">QWidget</a> * QApplication::activeModalWidget ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
412
<p>Returns the active modal widget.</p>
 
413
<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>
 
414
<p>Modal widgets are organized in a stack. This function returns the active modal widget at the top of the stack.</p>
 
415
<p>See also <a href="qapplication.html#activePopupWidget">activePopupWidget</a>() and <a href="qapplication.html#topLevelWidgets">topLevelWidgets</a>().</p>
 
416
<h3 class="fn"><a name="activePopupWidget"></a><a href="qwidget.html">QWidget</a> * QApplication::activePopupWidget ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
417
<p>Returns the active popup widget.</p>
 
418
<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>
 
419
<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>
 
420
<p>See also <a href="qapplication.html#activeModalWidget">activeModalWidget</a>() and <a href="qapplication.html#topLevelWidgets">topLevelWidgets</a>().</p>
 
421
<h3 class="fn"><a name="activeWindow"></a><a href="qwidget.html">QWidget</a> * QApplication::activeWindow ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
422
<p>Returns the application top-level window that has the keyboard input focus, or 0 if no application window has the focus. Note that 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>
 
423
<p>See also <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>
 
424
<h3 class="fn"><a name="allWidgets"></a>QWidgetList QApplication::allWidgets ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
425
<p>Returns a list of all the widgets in the application.</p>
 
426
<p>The list is empty (<a href="qlist.html#isEmpty">QList::isEmpty</a>()) if there are no widgets.</p>
 
427
<p>Note that some of the widgets may be hidden.</p>
 
428
<p>Example:</p>
 
429
<pre>&nbsp;   void updateAllWidgets()
 
430
    {
 
431
        foreach (QWidget *widget, QApplication::allWidgets())
 
432
            widget-&gt;update();
 
433
    }</pre>
 
434
<p>See also <a href="qapplication.html#topLevelWidgets">topLevelWidgets</a>() and <a href="qwidget.html#visible-prop">QWidget::isVisible</a>().</p>
 
435
<h3 class="fn"><a name="beep"></a>void QApplication::beep ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
436
<p>Sounds the bell, using the default volume and sound.</p>
 
437
<h3 class="fn"><a name="changeOverrideCursor"></a>void QApplication::changeOverrideCursor ( const <a href="qcursor.html">QCursor</a> &amp; <i>cursor</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
438
<p>Changes the currently active application override cursor to <i>cursor</i>.</p>
 
439
<p>This function has no effect if <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>() wasn't called.</p>
 
440
<p>See also <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>
 
441
<h3 class="fn"><a name="clipboard"></a><a href="qclipboard.html">QClipboard</a> * QApplication::clipboard ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
442
<p>Returns a pointer to the application global clipboard.</p>
 
443
<h3 class="fn"><a name="closeAllWindows"></a>void QApplication::closeAllWindows ()&nbsp;&nbsp;<tt> [static slot]</tt></h3>
 
444
<p>Closes all top-level windows.</p>
 
445
<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>
 
446
<pre>&nbsp;       exitAct = new QAction(tr(&quot;E&amp;xit&quot;), this);
 
447
        exitAct-&gt;setShortcut(tr(&quot;Ctrl+Q&quot;));
 
448
        exitAct-&gt;setStatusTip(tr(&quot;Exit the application&quot;));
 
449
        connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));</pre>
 
450
<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 of by setting <a href="qapplication.html#quitOnLastWindowClosed-prop">quitOnLastWindowClosed</a> to false.</p>
 
451
<p>See also <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>
 
452
<h3 class="fn"><a name="colorSpec"></a>int QApplication::colorSpec ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
453
<p>Returns the color specification.</p>
 
454
<p>See also <a href="qapplication.html#setColorSpec">QApplication::setColorSpec</a>().</p>
 
455
<h3 class="fn"><a name="commitData"></a>void QApplication::commitData ( <a href="qsessionmanager.html">QSessionManager</a> &amp; <i>manager</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
456
<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>
 
457
<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>
 
458
<p>Note that 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>
 
459
<p><b>Warning:</b> Within this function, no user interaction is possible, <i>unless</i> you ask the session manager <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>
 
460
<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>
 
461
<p>See also <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>
 
462
<h3 class="fn"><a name="desktop"></a><a href="qdesktopwidget.html">QDesktopWidget</a> * QApplication::desktop ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
463
<p>Returns the desktop widget (also called the root window).</p>
 
464
<p>The desktop widget is useful for obtaining the size of the screen. It may also be possible to draw on the desktop. We recommend against assuming that it's possible to draw on the desktop, since this does not work on all operating systems.</p>
 
465
<p>Example:</p>
 
466
<pre>&nbsp;   QDesktopWidget *desktop = QApplication::desktop();
 
467
    int width = desktop-&gt;width();
 
468
    int height = desktop-&gt;height();</pre>
 
469
<h3 class="fn"><a name="desktopSettingsAware"></a>bool QApplication::desktopSettingsAware ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
470
<p>Returns true if Qt is set to use the system's standard colors, fonts, etc.; otherwise returns false. The default is true.</p>
 
471
<p>See also <a href="qapplication.html#setDesktopSettingsAware">setDesktopSettingsAware</a>().</p>
 
472
<h3 class="fn"><a name="exec"></a>int QApplication::exec ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
473
<p>Enters the main event loop and waits until <a href="qcoreapplication.html#exit">exit</a>() is called or the main widget is destroyed, and 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>
 
474
<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>
 
475
<p>Generally speaking, 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>
 
476
<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>
 
477
<p>See also <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>
 
478
<h3 class="fn"><a name="focusWidget"></a><a href="qwidget.html">QWidget</a> * QApplication::focusWidget ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
479
<p>Returns the application widget that has the keyboard input focus, or 0 if no widget in this application has the focus.</p>
 
480
<p>See also <a href="qwidget.html#setFocus">QWidget::setFocus</a>(), <a href="qwidget.html#focus-prop">QWidget::hasFocus</a>(), and <a href="qapplication.html#activeWindow">activeWindow</a>().</p>
 
481
<h3 class="fn"><a name="font"></a><a href="qfont.html">QFont</a> QApplication::font ( const <a href="qwidget.html">QWidget</a> * <i>w</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
482
<p>Returns the default font for the widget <i>w</i>, or the default application font if <i>w</i> is 0.</p>
 
483
<p>See also <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>
 
484
<h3 class="fn"><a name="fontMetrics"></a><a href="qfontmetrics.html">QFontMetrics</a> QApplication::fontMetrics ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
485
<p>Returns display (screen) font metrics for the application font.</p>
 
486
<p>See also <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>
 
487
<h3 class="fn"><a name="inputContext"></a><a href="qinputcontext.html">QInputContext</a> * QApplication::inputContext () const</h3>
 
488
<p>Returns the <a href="qinputcontext.html">QInputContext</a> instance used by the application.</p>
 
489
<p>See also <a href="qapplication.html#setInputContext">setInputContext</a>().</p>
 
490
<h3 class="fn"><a name="isEffectEnabled"></a>bool QApplication::isEffectEnabled ( <a href="qt.html#UIEffect-enum">Qt::UIEffect</a> <i>effect</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
491
<p>Returns true if <i>effect</i> is enabled; otherwise returns false.</p>
 
492
<p>By default, Qt will try to use the desktop settings. Call setDesktopSettingsAware(false) to prevent this.</p>
 
493
<p>Note: All effects are disabled on screens running at less than 16-bit color depth.</p>
 
494
<p>See also <a href="qapplication.html#setEffectEnabled">setEffectEnabled</a>() and <a href="qt.html#UIEffect-enum">Qt::UIEffect</a>.</p>
 
495
<h3 class="fn"><a name="isLeftToRight"></a>bool QApplication::isLeftToRight ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
496
<p>Returns true if the application's layout direction is <a href="qt.html#LayoutDirection-enum">Qt::LeftToRight</a>; otherwise returns false.</p>
 
497
<p>See also <a href="qapplication.html#layoutDirection-prop">layoutDirection</a>() and <a href="qapplication.html#isRightToLeft">isRightToLeft</a>().</p>
 
498
<h3 class="fn"><a name="isRightToLeft"></a>bool QApplication::isRightToLeft ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
499
<p>Returns true if the application's layout direction is <a href="qt.html#LayoutDirection-enum">Qt::RightToLeft</a>; otherwise returns false.</p>
 
500
<p>See also <a href="qapplication.html#layoutDirection-prop">layoutDirection</a>() and <a href="qapplication.html#isLeftToRight">isLeftToRight</a>().</p>
 
501
<h3 class="fn"><a name="isSessionRestored"></a>bool QApplication::isSessionRestored () const</h3>
 
502
<p>Returns true if the application has been restored from an earlier <a href="session.html">session</a>; otherwise returns false.</p>
 
503
<p>See also <a href="qapplication.html#sessionId">sessionId</a>(), <a href="qapplication.html#commitData">commitData</a>(), and <a href="qapplication.html#saveState">saveState</a>().</p>
 
504
<h3 class="fn"><a name="keyboardModifiers"></a><a href="qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a> QApplication::keyboardModifiers ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
505
<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>
 
506
<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>
 
507
<p>See also <a href="qapplication.html#mouseButtons">mouseButtons</a>().</p>
 
508
<h3 class="fn"><a name="lastWindowClosed"></a>void QApplication::lastWindowClosed ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
509
<p>This signal is emitted when the user has closed the last top-level window.</p>
 
510
<p>By default <a href="qapplication.html">QApplication</a> implicitely quits when this signal is emitted. This feature be turned off by setting <a href="qapplication.html#quitOnLastWindowClosed-prop">quitOnLastWindowClosed</a> to false.</p>
 
511
<p>Only top-level windows with the <a href="qt.html#WidgetAttribute-enum">Qt::WA_QuitOnClose</a> attribute set are taken into account. For convenience, this attribute is not set for transient top-level widgets such as splash screens, popup menus, and dialogs.</p>
 
512
<p>See also <a href="qwidget.html#close">QWidget::close</a>().</p>
 
513
<h3 class="fn"><a name="macEventFilter"></a>bool QApplication::macEventFilter ( EventHandlerCallRef <i>caller</i>, EventRef <i>event</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
514
<p><b>Warning:</b> This virtual function is only implemented under Mac OS X.</p>
 
515
<p>If you create an application that inherits <a href="qapplication.html">QApplication</a> and reimplement this function, you get direct access to all Carbon Events that are received from Mac OS X with this function being called with the <i>caller</i> and the <i>event</i>.</p>
 
516
<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>
 
517
<h3 class="fn"><a name="mouseButtons"></a><a href="qt.html#MouseButton-enum">Qt::MouseButtons</a> QApplication::mouseButtons ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
518
<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 (QEvent::MousePress and QEvent::MouseRelease events).</p>
 
519
<p>It should be noted this may not reflect the actual buttons held on theinput device at the time of calling but rather the mouse buttons as last reported in one of the above events. If no mouse buttons rae being held <a href="qt.html#MouseButton-enum">Qt::NoButton</a> is returned.</p>
 
520
<p>See also <a href="qapplication.html#keyboardModifiers">keyboardModifiers</a>().</p>
 
521
<h3 class="fn"><a name="overrideCursor"></a><a href="qcursor.html">QCursor</a> * QApplication::overrideCursor ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
522
<p>Returns the active application override cursor.</p>
 
523
<p>This function returns 0 if no application cursor has been defined (i.e. the internal cursor stack is empty).</p>
 
524
<p>See also <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>() and <a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>().</p>
 
525
<h3 class="fn"><a name="palette"></a><a href="qpalette.html">QPalette</a> QApplication::palette ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
526
<p>Returns the application palette.</p>
 
527
<p>See also <a href="qapplication.html#setPalette">setPalette</a>() and <a href="qwidget.html#palette-prop">QWidget::palette</a>().</p>
 
528
<h3 class="fn"><a name="palette-2"></a><a href="qpalette.html">QPalette</a> QApplication::palette ( const <a href="qwidget.html">QWidget</a> * <i>w</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
529
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
530
<p>If a widget is passed in <i>w</i>, the default palette for the widget's class is returned. This may or may not be the application palette. In most cases there isn't a 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>
 
531
<p>See also <a href="qapplication.html#setPalette">setPalette</a>() and <a href="qwidget.html#palette-prop">QWidget::palette</a>().</p>
 
532
<h3 class="fn"><a name="palette-3"></a><a href="qpalette.html">QPalette</a> QApplication::palette ( const char * <i>className</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
533
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
534
<p>Returns the palette for widgets of the given <i>className</i>.</p>
 
535
<p>See also <a href="qapplication.html#setPalette">setPalette</a>() and <a href="qwidget.html#palette-prop">QWidget::palette</a>().</p>
 
536
<h3 class="fn"><a name="qwsDecoration"></a><a href="qdecoration.html">QDecoration</a> &amp; QApplication::qwsDecoration ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
537
<p>Return the QWSDecoration used for decorating windows.</p>
 
538
<p>This method is non-portable. It is available <i>only</i> in Qt/Embedded.</p>
 
539
<p>See also <a href="qdecoration.html">QDecoration</a>.</p>
 
540
<h3 class="fn"><a name="qwsEventFilter"></a>bool QApplication::qwsEventFilter ( <a href="qwsevent.html">QWSEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
541
<p><b>Warning:</b> This virtual function is only implemented under Qt/Embedded.</p>
 
542
<p>If you create an application that inherits <a href="qapplication.html">QApplication</a> and reimplement this function, you get direct access to all QWS (Q Window System) events that the are received from the QWS master process. The events are passed in the <i>event</i> parameter.</p>
 
543
<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>
 
544
<h3 class="fn"><a name="qwsSetCustomColors"></a>void QApplication::qwsSetCustomColors ( QRgb * <i>colorTable</i>, int <i>start</i>, int <i>numColors</i> )</h3>
 
545
<p>Set Qt/Embedded custom color table.</p>
 
546
<p>Qt/Embedded on 8-bpp displays allocates a standard 216 color cube. The remaining 40 colors may be used by setting a custom color table in the QWS master process before any clients connect.</p>
 
547
<p><i>colorTable</i> is an array of up to 40 custom colors. <i>start</i> is the starting index (0-39) and <i>numColors</i> is the number of colors to be set (1-40).</p>
 
548
<p>This method is non-portable. It is available <i>only</i> in Qt/Embedded.</p>
 
549
<h3 class="fn"><a name="qwsSetDecoration"></a>void QApplication::qwsSetDecoration ( <a href="qdecoration.html">QDecoration</a> * <i>dec</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
550
<p>Set the QWSDecoration derived class to use for decorating the Qt/Embedded windows to <i>dec</i>.</p>
 
551
<p>This method is non-portable. It is available <i>only</i> in Qt/Embedded.</p>
 
552
<p>See also <a href="qdecoration.html">QDecoration</a>.</p>
 
553
<h3 class="fn"><a name="qwsSetDecoration-2"></a><a href="qdecoration.html">QDecoration</a> * QApplication::qwsSetDecoration ( const <a href="qstring.html">QString</a> &amp; <i>decoration</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
554
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
555
<p>Requests a <a href="qdecoration.html">QDecoration</a> object for <i>decoration</i> from the <a href="qdecorationfactory.html">QDecorationFactory</a>.</p>
 
556
<p>The string must be one of the <a href="qstylefactory.html#keys">QStyleFactory::keys</a>().</p>
 
557
<p>A later call to the <a href="qapplication.html">QApplication</a> constructor will override the requested style when a &quot;-style&quot; option is passed in as a commandline parameter.</p>
 
558
<p>Returns 0 if an unknown <i>decoration</i> is passed, otherwise the <a href="qstyle.html">QStyle</a> object returned is set as the application's GUI style.</p>
 
559
<h3 class="fn"><a name="restoreOverrideCursor"></a>void QApplication::restoreOverrideCursor ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
560
<p>Undoes the last <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>().</p>
 
561
<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>
 
562
<p>See also <a href="qapplication.html#setOverrideCursor">setOverrideCursor</a>() and <a href="qapplication.html#overrideCursor">overrideCursor</a>().</p>
 
563
<h3 class="fn"><a name="saveState"></a>void QApplication::saveState ( <a href="qsessionmanager.html">QSessionManager</a> &amp; <i>manager</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
564
<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>
 
565
<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>
 
566
<p>Note that 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>
 
567
<p><b>Warning:</b> Within this function, no user interaction is possible, <i>unless</i> you ask the session manager <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>
 
568
<p>See also <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>
 
569
<h3 class="fn"><a name="sessionId"></a><a href="qstring.html">QString</a> QApplication::sessionId () const</h3>
 
570
<p>Returns the current <a href="session.html">session's</a> identifier.</p>
 
571
<p>If the application has been restored from an earlier session, this identifier is the same as it was in that previous session.</p>
 
572
<p>The session identifier is guaranteed to be unique both for different applications and for different instances of the same application.</p>
 
573
<p>See also <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>
 
574
<h3 class="fn"><a name="sessionKey"></a><a href="qstring.html">QString</a> QApplication::sessionKey () const</h3>
 
575
<p>Returns the session key in the current <a href="session.html">session</a>.</p>
 
576
<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>
 
577
<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>
 
578
<p>See also <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>
 
579
<h3 class="fn"><a name="setActiveWindow"></a>void QApplication::setActiveWindow ( <a href="qwidget.html">QWidget</a> * <i>act</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
580
<p>Sets the active window to the <i>act</i> widget in response to a system event. The function is called from the platform specific event handlers.</p>
 
581
<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>
 
582
<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>
 
583
<p>See also <a href="qapplication.html#activeWindow">activeWindow</a>() and <a href="qwidget.html#activateWindow">QWidget::activateWindow</a>().</p>
 
584
<h3 class="fn"><a name="setColorSpec"></a>void QApplication::setColorSpec ( int <i>spec</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
585
<p>Sets the color specification for the application to <i>spec</i>.</p>
 
586
<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>
 
587
<p>The color specification must be set before you create the <a href="qapplication.html">QApplication</a> object.</p>
 
588
<p>The options are:</p>
 
589
<ul>
 
590
<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 <a href="winsystem.html#x11">X11</a>, but on Windows machines it may cause dithering of non-standard colors.</li>
 
591
<li><a href="qapplication.html#ColorSpec-enum">QApplication::CustomColor</a>. Use this option if your application needs a small number of custom colors. On <a href="winsystem.html#x11">X11</a>, 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>
 
592
<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). Under <a href="winsystem.html#x11">X11</a> the effect is:<ul>
 
593
<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) &quot;Web palette&quot; (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>
 
594
<li>For 256-color displays which have a true color visual with more than 256 colors, use that visual. Silicon Graphics X servers have this feature, for example. They provide an 8 bit visual by default but can deliver true color when asked.</li>
 
595
</ul>
 
596
<p>On Windows, Qt creates a Windows palette, and fills it with a color cube.</p>
 
597
</li>
 
598
</ul>
 
599
<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>
 
600
<p>Example:</p>
 
601
<pre>&nbsp;   int main(int argc, char *argv[])
 
602
    {
 
603
        QApplication::setColorSpec(QApplication::ManyColor);
 
604
        QApplication app(argc, argv);
 
605
        ...
 
606
        return app.exec();
 
607
    }</pre>
 
608
<p>See also <a href="qapplication.html#colorSpec">colorSpec</a>().</p>
 
609
<h3 class="fn"><a name="setDesktopSettingsAware"></a>void QApplication::setDesktopSettingsAware ( bool <i>on</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
610
<p>Sets whether Qt should use the system's standard colors, fonts, etc., to <i>on</i>. By default, this is true.</p>
 
611
<p>This function must be called before creating the <a href="qapplication.html">QApplication</a> object, like this:</p>
 
612
<pre>&nbsp;   int main(int argc, char *argv[])
 
613
    {
 
614
        QApplication::setDesktopSettingsAware(false);
 
615
        QApplication app(argc, argv);
 
616
        ...
 
617
        return app.exec();
 
618
    }</pre>
 
619
<p>See also <a href="qapplication.html#desktopSettingsAware">desktopSettingsAware</a>().</p>
 
620
<h3 class="fn"><a name="setEffectEnabled"></a>void QApplication::setEffectEnabled ( <a href="qt.html#UIEffect-enum">Qt::UIEffect</a> <i>effect</i>, bool <i>enable</i> = true )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
621
<p>Enables the UI effect <i>effect</i> if <i>enable</i> is true, otherwise the effect will not be used.</p>
 
622
<p>Note: All effects are disabled on screens running at less than 16-bit color depth.</p>
 
623
<p>See also <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>
 
624
<h3 class="fn"><a name="setFont"></a>void QApplication::setFont ( const <a href="qfont.html">QFont</a> &amp; <i>font</i>, const char * <i>className</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
625
<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>
 
626
<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>
 
627
<p>See also <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>
 
628
<h3 class="fn"><a name="setInputContext"></a>void QApplication::setInputContext ( <a href="qinputcontext.html">QInputContext</a> * <i>inputContext</i> )</h3>
 
629
<p>This function replaces the <a href="qinputcontext.html">QInputContext</a> instance used by the application with <i>inputContext</i>.</p>
 
630
<p>See also <a href="qapplication.html#inputContext">inputContext</a>().</p>
 
631
<h3 class="fn"><a name="setOverrideCursor"></a>void QApplication::setOverrideCursor ( const <a href="qcursor.html">QCursor</a> &amp; <i>cursor</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
632
<p>Sets the application override cursor to <i>cursor</i>.</p>
 
633
<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>
 
634
<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>
 
635
<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. Every setOverrideCursor() must eventually be followed by a corresponding <a href="qapplication.html#restoreOverrideCursor">restoreOverrideCursor</a>(), otherwise the stack will never be emptied.</p>
 
636
<p>Example:</p>
 
637
<pre>&nbsp;   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
638
    calculateHugeMandelbrot();              // lunch time...
 
639
    QApplication::restoreOverrideCursor();</pre>
 
640
<p>See also <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>
 
641
<h3 class="fn"><a name="setPalette"></a>void QApplication::setPalette ( const <a href="qpalette.html">QPalette</a> &amp; <i>palette</i>, const char * <i>className</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
642
<p>Changes the default application palette to <i>palette</i>.</p>
 
643
<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>
 
644
<p>The palette may be changed according to the current GUI style in <a href="qstyle.html#polish">QStyle::polish</a>().</p>
 
645
<p>See also <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>
 
646
<h3 class="fn"><a name="setStyle"></a>void QApplication::setStyle ( <a href="qstyle.html">QStyle</a> * <i>style</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
647
<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.</p>
 
648
<p>Example usage:</p>
 
649
<pre>&nbsp;   QApplication::setStyle(new QWindowsStyle);</pre>
 
650
<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>
 
651
<p>See also <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>
 
652
<h3 class="fn"><a name="setStyle-2"></a><a href="qstyle.html">QStyle</a> * QApplication::setStyle ( const <a href="qstring.html">QString</a> &amp; <i>style</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
653
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
654
<p>Requests a <a href="qstyle.html">QStyle</a> object for <i>style</i> from the <a href="qstylefactory.html">QStyleFactory</a>.</p>
 
655
<p>The string must be one of the <a href="qstylefactory.html#keys">QStyleFactory::keys</a>(), typically one of &quot;windows&quot;, &quot;motif&quot;, &quot;cde&quot;, &quot;plastique&quot;, &quot;windowsxp&quot;, or &quot;macintosh&quot;.</p>
 
656
<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>
 
657
<h3 class="fn"><a name="style"></a><a href="qstyle.html">QStyle</a> * QApplication::style ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
658
<p>Returns the application's style object.</p>
 
659
<p>See also <a href="qapplication.html#setStyle">setStyle</a>() and <a href="qstyle.html">QStyle</a>.</p>
 
660
<h3 class="fn"><a name="syncX"></a>void QApplication::syncX ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
661
<p>Synchronizes with the X server in the <a href="winsystem.html#x11">X11</a> implementation. This normally takes some time. Does nothing on other platforms.</p>
 
662
<h3 class="fn"><a name="topLevelAt"></a><a href="qwidget.html">QWidget</a> * QApplication::topLevelAt ( const <a href="qpoint.html">QPoint</a> &amp; <i>p</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
663
<p>Returns the top-level widget at the point <i>p</i>.</p>
 
664
<h3 class="fn"><a name="topLevelAt-2"></a><a href="qwidget.html">QWidget</a> * QApplication::topLevelAt ( int <i>x</i>, int <i>y</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
665
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
666
<p>Returns the top-level widget at the point (<i>x</i>, <i>y</i>).</p>
 
667
<h3 class="fn"><a name="topLevelWidgets"></a>QWidgetList QApplication::topLevelWidgets ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
668
<p>Returns a list of the top-level widgets (windows) in the application.</p>
 
669
<p>Note that some of the top-level widgets may be hidden, for example a tooltip if no tooltip is currently shown.</p>
 
670
<p>Example:</p>
 
671
<pre>&nbsp;   void showAllHiddenTopLevelWidgets()
 
672
    {
 
673
        foreach (QWidget *widget, QApplication::topLevelWidgets()) {
 
674
            if (widget-&gt;isHidden())
 
675
                widget-&gt;show();
 
676
        }
 
677
    }</pre>
 
678
<p>See also <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>
 
679
<h3 class="fn"><a name="type"></a><a href="qapplication.html#Type-enum">Type</a> QApplication::type ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
680
<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>
 
681
<h3 class="fn"><a name="widgetAt"></a><a href="qwidget.html">QWidget</a> * QApplication::widgetAt ( const <a href="qpoint.html">QPoint</a> &amp; <i>p</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
682
<p>Returns the widget at global screen position <i>p</i>, or 0 if there is no Qt widget there.</p>
 
683
<p>This function can be slow.</p>
 
684
<p>See also <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>
 
685
<h3 class="fn"><a name="widgetAt-4"></a><a href="qwidget.html">QWidget</a> * QApplication::widgetAt ( int <i>x</i>, int <i>y</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
686
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
687
<p>Returns the widget at global screen position (<i>x</i>, <i>y</i>), or 0 if there is no Qt widget there.</p>
 
688
<h3 class="fn"><a name="winFocus"></a>void QApplication::winFocus ( <a href="qwidget.html">QWidget</a> * <i>widget</i>, bool <i>gotFocus</i> )</h3>
 
689
<p>If <i>gotFocus</i> is true, <i>widget</i> will become the active window. Otherwise the active window is reset to NULL.</p>
 
690
<h3 class="fn"><a name="x11EventFilter"></a>bool QApplication::x11EventFilter ( XEvent * <i>event</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
691
<p><b>Warning:</b> This virtual function is only implemented under <a href="winsystem.html#x11">X11</a>.</p>
 
692
<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>
 
693
<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>
 
694
<p>See also <a href="qapplication.html#x11ProcessEvent">x11ProcessEvent</a>().</p>
 
695
<h3 class="fn"><a name="x11ProcessEvent"></a>int QApplication::x11ProcessEvent ( XEvent * <i>event</i> )</h3>
 
696
<p>This function does the core processing of individual X <i>event</i>s, normally by dispatching Qt events to the right destination.</p>
 
697
<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>
 
698
<p>See also <a href="qapplication.html#x11EventFilter">x11EventFilter</a>().</p>
 
699
<p /><address><hr /><div align="center">
 
700
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
701
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
702
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
703
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
704
</tr></table></div></address></body>
 
705
</html>