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

« back to all changes in this revision

Viewing changes to doc/html/qcoreapplication.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/corelib/kernel/qcoreapplication.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QCoreApplication 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">QCoreApplication Class Reference</h1>
 
21
<p>The QCoreApplication class provides an event loop for console Qt applications. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QCoreApplication&gt;</pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
 
23
<p>Inherits <a href="qobject.html">QObject</a>.</p>
 
24
<p>Inherited by <a href="qapplication.html">QApplication</a>.</p>
 
25
<ul>
 
26
<li><a href="qcoreapplication-members.html">List of all members, including inherited members</a></li>
 
27
<li><a href="qcoreapplication-qt3.html">Qt 3 support members</a></li>
 
28
</ul>
 
29
<a name="public-types"></a>
 
30
<h3>Public Types</h3>
 
31
<ul>
 
32
<li><div class="fn"/>enum <b><a href="qcoreapplication.html#Encoding-enum">Encoding</a></b> { DefaultCodec, UnicodeUTF8 }</li>
 
33
<li><div class="fn"/>typedef <b><a href="qcoreapplication.html#EventFilter-typedef">EventFilter</a></b></li>
 
34
</ul>
 
35
<a name="properties"></a>
 
36
<h3>Properties</h3>
 
37
<ul>
 
38
<li><div class="fn"/><b><a href="qcoreapplication.html#applicationName-prop">applicationName</a></b> : QString</li>
 
39
<li><div class="fn"/><b><a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a></b> : QString</li>
 
40
<li><div class="fn"/><b><a href="qcoreapplication.html#organizationName-prop">organizationName</a></b> : QString</li>
 
41
</ul>
 
42
<ul>
 
43
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
44
</ul>
 
45
<a name="public-functions"></a>
 
46
<h3>Public Functions</h3>
 
47
<ul>
 
48
<li><div class="fn"/><b><a href="qcoreapplication.html#QCoreApplication">QCoreApplication</a></b> ( int &amp; <i>argc</i>, char ** <i>argv</i> )</li>
 
49
<li><div class="fn"/><b><a href="qcoreapplication.html#dtor.QCoreApplication">~QCoreApplication</a></b> ()</li>
 
50
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#filterEvent">filterEvent</a></b> ( void * <i>message</i>, long * <i>result</i> )</li>
 
51
<li><div class="fn"/>virtual bool <b><a href="qcoreapplication.html#notify">notify</a></b> ( QObject * <i>receiver</i>, QEvent * <i>event</i> )</li>
 
52
<li><div class="fn"/>EventFilter <b><a href="qcoreapplication.html#setEventFilter">setEventFilter</a></b> ( EventFilter <i>filter</i> )</li>
 
53
<li><div class="fn"/>virtual bool <b><a href="qcoreapplication.html#winEventFilter">winEventFilter</a></b> ( MSG * <i>msg</i>, long * <i>result</i> )</li>
 
54
</ul>
 
55
<ul>
 
56
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
57
</ul>
 
58
<a name="public-slots"></a>
 
59
<h3>Public Slots</h3>
 
60
<ul>
 
61
<li><div class="fn"/>void <b><a href="qcoreapplication.html#quit">quit</a></b> ()</li>
 
62
</ul>
 
63
<ul>
 
64
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
65
</ul>
 
66
<a name="signals"></a>
 
67
<h3>Signals</h3>
 
68
<ul>
 
69
<li><div class="fn"/>void <b><a href="qcoreapplication.html#aboutToQuit">aboutToQuit</a></b> ()</li>
 
70
<li><div class="fn"/>void <b><a href="qcoreapplication.html#unixSignal">unixSignal</a></b> ( int <i>number</i> )</li>
 
71
</ul>
 
72
<ul>
 
73
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
74
</ul>
 
75
<a name="static-public-members"></a>
 
76
<h3>Static Public Members</h3>
 
77
<ul>
 
78
<li><div class="fn"/>void <b><a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a></b> ( const QString &amp; <i>path</i> )</li>
 
79
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#applicationDirPath">applicationDirPath</a></b> ()</li>
 
80
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a></b> ()</li>
 
81
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#applicationName-prop">applicationName</a></b> ()</li>
 
82
<li><div class="fn"/>int <b><a href="qcoreapplication.html#argc">argc</a></b> ()</li>
 
83
<li><div class="fn"/>char ** <b><a href="qcoreapplication.html#argv">argv</a></b> ()</li>
 
84
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#closingDown">closingDown</a></b> ()</li>
 
85
<li><div class="fn"/>int <b><a href="qcoreapplication.html#exec">exec</a></b> ()</li>
 
86
<li><div class="fn"/>void <b><a href="qcoreapplication.html#exit">exit</a></b> ( int <i>returnCode</i> = 0 )</li>
 
87
<li><div class="fn"/>void <b><a href="qcoreapplication.html#flush">flush</a></b> ()</li>
 
88
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#hasPendingEvents">hasPendingEvents</a></b> ()</li>
 
89
<li><div class="fn"/>void <b><a href="qcoreapplication.html#installTranslator">installTranslator</a></b> ( QTranslator * <i>mf</i> )</li>
 
90
<li><div class="fn"/>QCoreApplication * <b><a href="qcoreapplication.html#instance">instance</a></b> ()</li>
 
91
<li><div class="fn"/>QStringList <b><a href="qcoreapplication.html#libraryPaths">libraryPaths</a></b> ()</li>
 
92
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a></b> ()</li>
 
93
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#organizationName-prop">organizationName</a></b> ()</li>
 
94
<li><div class="fn"/>void <b><a href="qcoreapplication.html#postEvent">postEvent</a></b> ( QObject * <i>receiver</i>, QEvent * <i>event</i> )</li>
 
95
<li><div class="fn"/>void <b><a href="qcoreapplication.html#processEvents">processEvents</a></b> ( QEventLoop::ProcessEventsFlags <i>flags</i> = QEventLoop::AllEvents )</li>
 
96
<li><div class="fn"/>void <b><a href="qcoreapplication.html#processEvents-2">processEvents</a></b> ( QEventLoop::ProcessEventsFlags <i>flags</i>, int <i>maxtime</i> )</li>
 
97
<li><div class="fn"/>void <b><a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a></b> ( const QString &amp; <i>path</i> )</li>
 
98
<li><div class="fn"/>void <b><a href="qcoreapplication.html#removePostedEvents">removePostedEvents</a></b> ( QObject * <i>receiver</i> )</li>
 
99
<li><div class="fn"/>void <b><a href="qcoreapplication.html#removeTranslator">removeTranslator</a></b> ( QTranslator * <i>mf</i> )</li>
 
100
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#sendEvent">sendEvent</a></b> ( QObject * <i>receiver</i>, QEvent * <i>event</i> )</li>
 
101
<li><div class="fn"/>void <b><a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a></b> ( QObject * <i>receiver</i>, int <i>event_type</i> )</li>
 
102
<li><div class="fn"/>void <b><a href="qcoreapplication.html#sendPostedEvents-2">sendPostedEvents</a></b> ()</li>
 
103
<li><div class="fn"/>void <b><a href="qcoreapplication.html#applicationName-prop">setApplicationName</a></b> ( const QString &amp; <i>application</i> )</li>
 
104
<li><div class="fn"/>void <b><a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a></b> ( const QStringList &amp; <i>paths</i> )</li>
 
105
<li><div class="fn"/>void <b><a href="qcoreapplication.html#organizationDomain-prop">setOrganizationDomain</a></b> ( const QString &amp; <i>orgDomain</i> )</li>
 
106
<li><div class="fn"/>void <b><a href="qcoreapplication.html#organizationName-prop">setOrganizationName</a></b> ( const QString &amp; <i>orgName</i> )</li>
 
107
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#startingUp">startingUp</a></b> ()</li>
 
108
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#translate">translate</a></b> ( const char * <i>context</i>, const char * <i>sourceText</i>, const char * <i>comment</i> = 0, Encoding <i>encoding</i> = DefaultCodec )</li>
 
109
</ul>
 
110
<ul>
 
111
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
112
</ul>
 
113
<a name="related-non-members"></a>
 
114
<h3>Related Non-Members</h3>
 
115
<ul>
 
116
<li><div class="fn"/>void <b><a href="qcoreapplication.html#qAddPostRoutine">qAddPostRoutine</a></b> ( QtCleanUpFunction <i>ptr</i> )</li>
 
117
</ul>
 
118
<h3>Additional Inherited Members</h3>
 
119
<ul>
 
120
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
121
</ul>
 
122
<a name="details"></a>
 
123
<hr />
 
124
<h2>Detailed Description</h2>
 
125
<p>The QCoreApplication class provides an event loop for console Qt applications.</p>
 
126
<p>This class is used by non-GUI applications to provide their event loop. For non-GUI application that uses Qt, there should be exactly one QCoreApplication object. For GUI applications, see <a href="qapplication.html">QApplication</a>.</p>
 
127
<p>QCoreApplication contains the main event loop, where all events from the operating system (e.g., timer and network events) and other sources are processed and dispatched. It also handles the application's initialization and finalization, as well as system-wide and application-wide settings.</p>
 
128
<p>The command line arguments which QCoreApplication's constructor should be called with are accessible using <a href="qcoreapplication.html#argc">argc</a>() and <a href="qcoreapplication.html#argv">argv</a>(). The event loop is started with a call to <a href="qcoreapplication.html#exec">exec</a>(). Long running operations can call <a href="qcoreapplication.html#processEvents">processEvents</a>() to keep the application responsive.</p>
 
129
<p>Some Qt classes (e.g., <a href="qstring.html">QString</a>) can be used without a QCoreApplication object. However, in general, we recommend that you create a QCoreApplication or a <a href="qapplication.html">QApplication</a> object in your <tt>main()</tt> function as early as possible.</p>
 
130
<p>An application has an <a href="qcoreapplication.html#applicationDirPath">applicationDirPath</a>() and an <a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a>(). Translation files can be added or removed using <a href="qcoreapplication.html#installTranslator">installTranslator</a>() and <a href="qcoreapplication.html#removeTranslator">removeTranslator</a>(). Application strings can be translated using <a href="qcoreapplication.html#translate">translate</a>(). The <a href="qobject.html#tr">QObject::tr</a>() and <a href="qobject.html#trUtf8">QObject::trUtf8</a>() functions are implemented in terms of <a href="qcoreapplication.html#translate">translate</a>().</p>
 
131
<p>The class provides a <a href="qcoreapplication.html#quit">quit</a>() slot and an <a href="qcoreapplication.html#aboutToQuit">aboutToQuit</a>() signal.</p>
 
132
<p>Several static convenience functions are also provided. The QCoreApplication object is available from <a href="qcoreapplication.html#instance">instance</a>(). Events can be sent or posted using <a href="qcoreapplication.html#sendEvent">sendEvent</a>(), <a href="qcoreapplication.html#postEvent">postEvent</a>(), and <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>(). Pending events can be removed with <a href="qcoreapplication.html#removePostedEvents">removePostedEvents</a>() or flushed with <a href="qcoreapplication.html#flush">flush</a>(). Library paths (see <a href="qlibrary.html">QLibrary</a>) can be retrieved with <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>() and manipulated by <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>(), <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), and <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>().</p>
 
133
<p>See also <a href="qapplication.html">QApplication</a>, <a href="qabstracteventdispatcher.html">QAbstractEventDispatcher</a>, and <a href="qeventloop.html">QEventLoop</a>.</p>
 
134
<hr />
 
135
<h2>Member Type Documentation</h2>
 
136
<h3 class="fn"><a name="Encoding-enum"></a>enum QCoreApplication::Encoding</h3>
 
137
<p>This enum type defines the 8-bit encoding of character string arguments to <a href="qcoreapplication.html#translate">translate</a>():</p>
 
138
<table border="1" cellpadding="2" cellspacing="1" width="100%">
 
139
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
 
140
<tr><td valign="top"><tt>QCoreApplication::DefaultCodec</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">The encoding specified by <a href="qtextcodec.html#codecForTr">QTextCodec::codecForTr</a>() (Latin1 if none has been set)</td></tr>
 
141
<tr><td valign="top"><tt>QCoreApplication::UnicodeUTF8</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">UTF-8</td></tr>
 
142
</table>
 
143
<p>See also <a href="qobject.html#tr">QObject::tr</a>(), <a href="qobject.html#trUtf8">QObject::trUtf8</a>(), and <a href="qstring.html#fromUtf8">QString::fromUtf8</a>().</p>
 
144
<h3 class="fn"><a name="EventFilter-typedef"></a>typedef QCoreApplication::EventFilter</h3>
 
145
<p>A function with the following signature that can be used as an event filter:</p>
 
146
<pre>&nbsp;   bool myEventFilter(void *message, long *result);</pre>
 
147
<p>See also <a href="qcoreapplication.html#setEventFilter">setEventFilter</a>().</p>
 
148
<hr />
 
149
<h2>Property Documentation</h2>
 
150
<h3 class="fn"><a name="applicationName-prop"></a>applicationName : <a href="qstring.html">QString</a></h3>
 
151
<p>This property holds the name of this application.</p>
 
152
<p>The value is used by the <a href="qsettings.html">QSettings</a> class when it is constructed using the empty constructor. This saves having to repeat this information each time a <a href="qsettings.html">QSettings</a> object is created.</p>
 
153
<p>Access functions:</p>
 
154
<ul>
 
155
<li><div class="fn"/><b>QString applicationName ()</b></li>
 
156
<li><div class="fn"/><b>void setApplicationName ( const QString &amp; <i>application</i> )</b></li>
 
157
</ul>
 
158
<p>See also <a href="qcoreapplication.html#organizationName-prop">organizationName</a> and <a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a>.</p>
 
159
<h3 class="fn"><a name="organizationDomain-prop"></a>organizationDomain : <a href="qstring.html">QString</a></h3>
 
160
<p>This property holds the Internet domain of the organization that wrote this application.</p>
 
161
<p>The value is used by the <a href="qsettings.html">QSettings</a> class when it is constructed using the empty constructor. This saves having to repeat this information each time a <a href="qsettings.html">QSettings</a> object is created.</p>
 
162
<p>On Mac, <a href="qsettings.html">QSettings</a> uses organizationDomain() as the organization if it's not an empty string; otherwise it uses <a href="qcoreapplication.html#organizationName-prop">organizationName</a>(). On all other platforms, <a href="qsettings.html">QSettings</a> uses <a href="qcoreapplication.html#organizationName-prop">organizationName</a>() as the organization.</p>
 
163
<p>Access functions:</p>
 
164
<ul>
 
165
<li><div class="fn"/><b>QString organizationDomain ()</b></li>
 
166
<li><div class="fn"/><b>void setOrganizationDomain ( const QString &amp; <i>orgDomain</i> )</b></li>
 
167
</ul>
 
168
<p>See also <a href="qcoreapplication.html#organizationName-prop">organizationName</a> and <a href="qcoreapplication.html#applicationName-prop">applicationName</a>.</p>
 
169
<h3 class="fn"><a name="organizationName-prop"></a>organizationName : <a href="qstring.html">QString</a></h3>
 
170
<p>This property holds the name of the organization that wrote this application.</p>
 
171
<p>The value is used by the <a href="qsettings.html">QSettings</a> class when it is constructed using the empty constructor. This saves having to repeat this information each time a <a href="qsettings.html">QSettings</a> object is created.</p>
 
172
<p>On Mac, <a href="qsettings.html">QSettings</a> uses <a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a>() as the organization if it's not an empty string; otherwise it uses organizationName(). On all other platforms, <a href="qsettings.html">QSettings</a> uses organizationName() as the organization.</p>
 
173
<p>Access functions:</p>
 
174
<ul>
 
175
<li><div class="fn"/><b>QString organizationName ()</b></li>
 
176
<li><div class="fn"/><b>void setOrganizationName ( const QString &amp; <i>orgName</i> )</b></li>
 
177
</ul>
 
178
<p>See also <a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a> and <a href="qcoreapplication.html#applicationName-prop">applicationName</a>.</p>
 
179
<hr />
 
180
<h2>Member Function Documentation</h2>
 
181
<h3 class="fn"><a name="QCoreApplication"></a>QCoreApplication::QCoreApplication ( int &amp; <i>argc</i>, char ** <i>argv</i> )</h3>
 
182
<p>Constructs a Qt kernel application. Kernel applications are applications without a graphical user interface. These type of applications are used at the console or as server processes.</p>
 
183
<p>The <i>argc</i> and <i>argv</i> arguments are available from <a href="qcoreapplication.html#argc">argc</a>() and <a href="qcoreapplication.html#argv">argv</a>().</p>
 
184
<h3 class="fn"><a name="dtor.QCoreApplication"></a>QCoreApplication::~QCoreApplication ()</h3>
 
185
<p>Destroys the <a href="qcoreapplication.html">QCoreApplication</a> object.</p>
 
186
<h3 class="fn"><a name="aboutToQuit"></a>void QCoreApplication::aboutToQuit ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
187
<p>This signal is emitted when the application is about to quit the main event loop, e.g. when the event loop level drops to zero. This may happen either after a call to <a href="qcoreapplication.html#quit">quit</a>() from inside the application or when the users shuts down the entire desktop session.</p>
 
188
<p>The signal is particularly useful if your application has to do some last-second cleanup. Note that no user interaction is possible in this state.</p>
 
189
<p>See also <a href="qcoreapplication.html#quit">quit</a>().</p>
 
190
<h3 class="fn"><a name="addLibraryPath"></a>void QCoreApplication::addLibraryPath ( const <a href="qstring.html">QString</a> &amp; <i>path</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
191
<p>Appends <i>path</i> to the end of the library path list. If <i>path</i> is empty or already in the path list, the path list is not changed.</p>
 
192
<p>The default path list consists of a single entry, the installation directory for plugins. The default installation directory for plugins is <tt>INSTALL/plugins</tt>, where <tt>INSTALL</tt> is the directory where Qt was installed.</p>
 
193
<p>See also <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>(), <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>(), and <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>().</p>
 
194
<h3 class="fn"><a name="applicationDirPath"></a><a href="qstring.html">QString</a> QCoreApplication::applicationDirPath ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
195
<p>Returns the directory that contains the application executable.</p>
 
196
<p>For example, if you have installed Qt in the <tt>C:\Trolltech\Qt</tt> directory, and you run the <tt>launcher</tt> example, this function will return &quot;C:/Trolltech/Qt/examples/tools/launcher&quot;.</p>
 
197
<p>On Mac OS X this will point to the directory actually containing the executable, which may be inside of an application bundle (if the application is bundled).</p>
 
198
<p><b>Warning:</b> On Unix, this function assumes that argv[0] contains the file name of the executable (which it normally does). It also assumes that the current directory hasn't been changed by the application.</p>
 
199
<p>See also <a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a>().</p>
 
200
<h3 class="fn"><a name="applicationFilePath"></a><a href="qstring.html">QString</a> QCoreApplication::applicationFilePath ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
201
<p>Returns the file path of the application executable.</p>
 
202
<p>For example, if you have installed Qt in the <tt>/usr/local/qt</tt> directory, and you run the <tt>launcher</tt> example, this function will return &quot;/usr/local/qt/examples/tools/launcher&quot;.</p>
 
203
<p><b>Warning:</b> On Unix, this function assumes that argv[0] contains the file name of the executable (which it normally does). It also assumes that the current directory hasn't been changed by the application.</p>
 
204
<p>See also <a href="qcoreapplication.html#applicationDirPath">applicationDirPath</a>().</p>
 
205
<h3 class="fn"><a name="argc"></a>int QCoreApplication::argc ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
206
<p>Returns the number of command line arguments.</p>
 
207
<p>The documentation for <a href="qcoreapplication.html#argv">argv</a>() describes how to process command line arguments.</p>
 
208
<p>See also <a href="qcoreapplication.html#argv">argv</a>().</p>
 
209
<h3 class="fn"><a name="argv"></a>char ** QCoreApplication::argv ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
210
<p>Returns the command-line argument array.</p>
 
211
<p>argv()[0] is the program name, argv()[1] is the first argument, and argv()[<a href="qcoreapplication.html#argc">argc</a>() - 1] is the last argument.</p>
 
212
<p>A <a href="qcoreapplication.html">QCoreApplication</a> object is constructed by passing <i>argc</i> and <i>argv</i> from the <tt>main()</tt> function. Some of the arguments may be recognized as Qt options and removed from the argument vector. For example, the <a href="winsystem.html#x11">X11</a> version of <a href="qapplication.html">QApplication</a> knows about <tt>-display</tt>, <tt>-font</tt>, and a few more options.</p>
 
213
<p><a href="qcoreapplication.html#instance">QCoreApplication::instance</a>() points to the <a href="qcoreapplication.html">QCoreApplication</a> object, and through which you can access <a href="qcoreapplication.html#argc">argc</a>() and argv() in functions other than main().</p>
 
214
<p>See also <a href="qcoreapplication.html#argc">argc</a>().</p>
 
215
<h3 class="fn"><a name="closingDown"></a>bool QCoreApplication::closingDown ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
216
<p>Returns true if the application objects are being destroyed; otherwise returns false.</p>
 
217
<p>See also <a href="qcoreapplication.html#startingUp">startingUp</a>().</p>
 
218
<h3 class="fn"><a name="exec"></a>int QCoreApplication::exec ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
219
<p>Enters the main event loop and waits until <a href="qcoreapplication.html#exit">exit</a>() is called. 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>
 
220
<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>
 
221
<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>
 
222
<p>See also <a href="qcoreapplication.html#quit">quit</a>(), <a href="qcoreapplication.html#exit">exit</a>(), <a href="qcoreapplication.html#processEvents">processEvents</a>(), and <a href="qapplication.html#exec">QApplication::exec</a>().</p>
 
223
<h3 class="fn"><a name="exit"></a>void QCoreApplication::exit ( int <i>returnCode</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
224
<p>Tells the application to exit with a return code.</p>
 
225
<p>After this function has been called, the application leaves the main event loop and returns from the call to <a href="qcoreapplication.html#exec">exec</a>(). The <a href="qcoreapplication.html#exec">exec</a>() function returns <i>returnCode</i>.</p>
 
226
<p>By convention, a <i>returnCode</i> of 0 means success, and any non-zero value indicates an error.</p>
 
227
<p>Note that unlike the C library function of the same name, this function <i>does</i> return to the caller -- it is event processing that stops.</p>
 
228
<p>See also <a href="qcoreapplication.html#quit">quit</a>() and <a href="qcoreapplication.html#exec">exec</a>().</p>
 
229
<h3 class="fn"><a name="filterEvent"></a>bool QCoreApplication::filterEvent ( void * <i>message</i>, long * <i>result</i> )</h3>
 
230
<p>Sends <i>message</i> through the event filter that was set by <a href="qcoreapplication.html#setEventFilter">setEventFilter</a>(). If no event filter has been set, this function returns false; otherwise, this function returns the result of the event filter function in the <i>result</i> parameter.</p>
 
231
<p>See also <a href="qcoreapplication.html#setEventFilter">setEventFilter</a>().</p>
 
232
<h3 class="fn"><a name="flush"></a>void QCoreApplication::flush ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
233
<p>Flushes the platform specific event queues.</p>
 
234
<p>If you are doing graphical changes inside a loop that does not return to the event loop on asynchronous window systems like <a href="winsystem.html#x11">X11</a> or double buffered window systems like Mac OS X, and you want to visualize these changes immediately (e.g. Splash Screens), call this function.</p>
 
235
<p>See also <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>().</p>
 
236
<h3 class="fn"><a name="hasPendingEvents"></a>bool QCoreApplication::hasPendingEvents ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
237
<p>This function returns true if there are pending events; otherwise returns false. Pending events can be either from the window system or posted events using <a href="qcoreapplication.html#postEvent">postEvent</a>().</p>
 
238
<p>See also <a href="qabstracteventdispatcher.html#hasPendingEvents">QAbstractEventDispatcher::hasPendingEvents</a>().</p>
 
239
<h3 class="fn"><a name="installTranslator"></a>void QCoreApplication::installTranslator ( <a href="qtranslator.html">QTranslator</a> * <i>mf</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
240
<p>Adds the message file <i>mf</i> to the list of message files to be used for translations.</p>
 
241
<p>Multiple message files can be installed. Translations are searched for in the last installed message file, then the one from last, and so on, back to the first installed message file. The search stops as soon as a matching translation is found.</p>
 
242
<p>See also <a href="qcoreapplication.html#removeTranslator">removeTranslator</a>(), <a href="qcoreapplication.html#translate">translate</a>(), and <a href="qtranslator.html#load">QTranslator::load</a>().</p>
 
243
<h3 class="fn"><a name="instance"></a>QCoreApplication * QCoreApplication::instance ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
244
<p>Returns a pointer to the application's <a href="qcoreapplication.html">QCoreApplication</a> (or <a href="qapplication.html">QApplication</a>) instance.</p>
 
245
<h3 class="fn"><a name="libraryPaths"></a><a href="qstringlist.html">QStringList</a> QCoreApplication::libraryPaths ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
246
<p>Returns a list of paths that the application will search when dynamically loading libraries. The installation directory for plugins is the only entry if no paths have been set. The default installation directory for plugins is <tt>INSTALL/plugins</tt>, where <tt>INSTALL</tt> is the directory where Qt was installed. The directory of the application executable (NOT the working directory) is also added to the plugin paths, as well as the colon separated entries of the QT_PLUGIN_PATH environment variable.</p>
 
247
<p>If you want to iterate over the list, you can use the <a href="containers.html#foreach">foreach</a> pseudo-keyword:</p>
 
248
<pre>&nbsp;   foreach (QString path, app.libraryPaths())
 
249
        do_something(path);</pre>
 
250
<p>See also <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>(), <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>(), <a href="qlibrary.html">QLibrary</a>, and <a href="plugins-howto.html">How to Create Qt Plugins</a>.</p>
 
251
<h3 class="fn"><a name="notify"></a>bool QCoreApplication::notify ( <a href="qobject.html">QObject</a> * <i>receiver</i>, <a href="qevent.html">QEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
252
<p>Sends <i>event</i> to <i>receiver</i>: <i>receiver</i>-&gt;event(<i>event</i>). Returns the value that is returned from the receiver's event handler.</p>
 
253
<p>For certain types of events (e.g. mouse and key events), the event will be propagated to the receiver's parent and so on up to the top-level object if the receiver is not interested in the event (i.e., it returns false).</p>
 
254
<p>There are five different ways that events can be processed; reimplementing this virtual function is just one of them. All five approaches are listed below:</p>
 
255
<ol type="1">
 
256
<li>Reimplementing this function. This is very powerful, providing complete control; but only one subclass can be active at a time.</li>
 
257
<li>Installing an event filter on <a href="qcoreapplication.html#instance">QCoreApplication::instance</a>(). Such an event filter is able to process all events for all widgets, so it's just as powerful as reimplementing notify(); furthermore, it's possible to have more than one application-global event filter. Global event filters even see mouse events for <a href="qwidget.html#enabled-prop">disabled widgets</a>.</li>
 
258
<li>Reimplementing <a href="qobject.html#event">QObject::event</a>() (as <a href="qwidget.html">QWidget</a> does). If you do this you get Tab key presses, and you get to see the events before any widget-specific event filters.</li>
 
259
<li>Installing an event filter on the object. Such an event filter gets all the events except Tab and Shift-Tab key presses.</li>
 
260
<li>Reimplementing paintEvent(), mousePressEvent() and so on. This is the commonest, easiest and least powerful way.</li>
 
261
</ol>
 
262
<p>See also <a href="qobject.html#event">QObject::event</a>() and <a href="qobject.html#installEventFilter">installEventFilter</a>().</p>
 
263
<h3 class="fn"><a name="postEvent"></a>void QCoreApplication::postEvent ( <a href="qobject.html">QObject</a> * <i>receiver</i>, <a href="qevent.html">QEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
264
<p>Adds the event <i>event</i> with the object <i>receiver</i> as the receiver of the event, to an event queue and returns immediately.</p>
 
265
<p>The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been posted. It is <i>not safe</i> to modify or delete the event after it has been posted.</p>
 
266
<p>When control returns to the main event loop, all events that are stored in the queue will be sent using the <a href="qcoreapplication.html#notify">notify</a>() function.</p>
 
267
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
 
268
<p>See also <a href="qcoreapplication.html#sendEvent">sendEvent</a>() and <a href="qcoreapplication.html#notify">notify</a>().</p>
 
269
<h3 class="fn"><a name="processEvents"></a>void QCoreApplication::processEvents ( <a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::ProcessEventsFlags</a> <i>flags</i> = QEventLoop::AllEvents )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
270
<p>Processes all pending events according to the specified <i>flags</i> until there are no more events to process.</p>
 
271
<p>You can call this function occasionally when your program is busy performing a long operation (e.g. copying a file).</p>
 
272
<p>See also <a href="qcoreapplication.html#exec">exec</a>(), <a href="qtimer.html">QTimer</a>, and <a href="qeventloop.html#processEvents">QEventLoop::processEvents</a>().</p>
 
273
<h3 class="fn"><a name="processEvents-2"></a>void QCoreApplication::processEvents ( <a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::ProcessEventsFlags</a> <i>flags</i>, int <i>maxtime</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
274
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
275
<p>Processes pending events for <i>maxtime</i> milliseconds or until there are no more events to process, whichever is shorter.</p>
 
276
<p>You can call this function occasionally when you program is busy doing a long operation (e.g. copying a file).</p>
 
277
<p>See also <a href="qcoreapplication.html#exec">exec</a>(), <a href="qtimer.html">QTimer</a>, and <a href="qeventloop.html#processEvents">QEventLoop::processEvents</a>().</p>
 
278
<h3 class="fn"><a name="quit"></a>void QCoreApplication::quit ()&nbsp;&nbsp;<tt> [static slot]</tt></h3>
 
279
<p>Tells the application to exit with return code 0 (success). Equivalent to calling QCoreApplication::exit(0).</p>
 
280
<p>It's common to connect the <a href="qapplication.html#lastWindowClosed">QApplication::lastWindowClosed</a>() signal to quit(), and you also often connect e.g. <a href="qabstractbutton.html#clicked">QAbstractButton::clicked</a>() or signals in <a href="qaction.html">QAction</a>, <a href="qmenu.html">QMenu</a>, or <a href="qmenubar.html">QMenuBar</a> to it.</p>
 
281
<p>Example:</p>
 
282
<pre>&nbsp;   QPushButton *quitButton = new QPushButton(&quot;Quit&quot;);
 
283
    connect(quitButton, SIGNAL(clicked()), &amp;app, SLOT(quit()));</pre>
 
284
<p>See also <a href="qcoreapplication.html#exit">exit</a>(), <a href="qcoreapplication.html#aboutToQuit">aboutToQuit</a>(), and <a href="qapplication.html#lastWindowClosed">QApplication::lastWindowClosed</a>().</p>
 
285
<h3 class="fn"><a name="removeLibraryPath"></a>void QCoreApplication::removeLibraryPath ( const <a href="qstring.html">QString</a> &amp; <i>path</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
286
<p>Removes <i>path</i> from the library path list. If <i>path</i> is empty or not in the path list, the list is not changed.</p>
 
287
<p>See also <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>(), and <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>().</p>
 
288
<h3 class="fn"><a name="removePostedEvents"></a>void QCoreApplication::removePostedEvents ( <a href="qobject.html">QObject</a> * <i>receiver</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
289
<p>Removes all events posted using <a href="qcoreapplication.html#postEvent">postEvent</a>() for <i>receiver</i>.</p>
 
290
<p>The events are <i>not</i> dispatched, instead they are removed from the queue. You should never need to call this function. If you do call it, be aware that killing events may cause <i>receiver</i> to break one or more invariants.</p>
 
291
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
 
292
<h3 class="fn"><a name="removeTranslator"></a>void QCoreApplication::removeTranslator ( <a href="qtranslator.html">QTranslator</a> * <i>mf</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
293
<p>Removes the message file <i>mf</i> from the list of message files used by this application. (It does not delete the message file from the file system.)</p>
 
294
<p>See also <a href="qcoreapplication.html#installTranslator">installTranslator</a>(), <a href="qcoreapplication.html#translate">translate</a>(), and <a href="qobject.html#tr">QObject::tr</a>().</p>
 
295
<h3 class="fn"><a name="sendEvent"></a>bool QCoreApplication::sendEvent ( <a href="qobject.html">QObject</a> * <i>receiver</i>, <a href="qevent.html">QEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
296
<p>Sends event <i>event</i> directly to receiver <i>receiver</i>, using the <a href="qcoreapplication.html#notify">notify</a>() function. Returns the value that was returned from the event handler.</p>
 
297
<p>The event is <i>not</i> deleted when the event has been sent. The normal approach is to create the event on the stack, for example:</p>
 
298
<pre>&nbsp;   QMouseEvent event(QEvent::MouseButtonPress, pos, 0, 0);
 
299
    QApplication::sendEvent(mainWindow, &amp;event);</pre>
 
300
<p>See also <a href="qcoreapplication.html#postEvent">postEvent</a>() and <a href="qcoreapplication.html#notify">notify</a>().</p>
 
301
<h3 class="fn"><a name="sendPostedEvents"></a>void QCoreApplication::sendPostedEvents ( <a href="qobject.html">QObject</a> * <i>receiver</i>, int <i>event_type</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
302
<p>Immediately dispatches all events which have been previously queued with <a href="qcoreapplication.html#postEvent">QCoreApplication::postEvent</a>() and which are for the object <i>receiver</i> and have the event type <i>event_type</i>.</p>
 
303
<p>Note that events from the window system are <i>not</i> dispatched by this function, but by <a href="qcoreapplication.html#processEvents">processEvents</a>().</p>
 
304
<p>If <i>receiver</i> is null, the events of <i>event_type</i> are sent for all objects. If <i>event_type</i> is 0, all the events are sent for <i>receiver</i>.</p>
 
305
<h3 class="fn"><a name="sendPostedEvents-2"></a>void QCoreApplication::sendPostedEvents ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
306
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
307
<p>Dispatches all posted events, i.e. empties the event queue.</p>
 
308
<h3 class="fn"><a name="setEventFilter"></a><a href="qcoreapplication.html#EventFilter-typedef">EventFilter</a> QCoreApplication::setEventFilter ( <a href="qcoreapplication.html#EventFilter-typedef">EventFilter</a> <i>filter</i> )</h3>
 
309
<p>Sets the event filter <i>filter</i>. Returns a pointer to the filter function previously defined.</p>
 
310
<p>The event filter is a function that is called for every message received in all threads. This does <i>not</i> include messages to objects that are not handled by Qt.</p>
 
311
<p>The function can return true to stop the event to be processed by Qt, or false to continue with the standard event processing.</p>
 
312
<p>Only one filter can be defined, but the filter can use the return value to call the previously set event filter. By default, no filter is set (i.e., the function returns 0).</p>
 
313
<p>See also <a href="qobject.html#installEventFilter">installEventFilter</a>().</p>
 
314
<h3 class="fn"><a name="setLibraryPaths"></a>void QCoreApplication::setLibraryPaths ( const <a href="qstringlist.html">QStringList</a> &amp; <i>paths</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
315
<p>Sets the list of directories to search when loading libraries to <i>paths</i>. All existing paths will be deleted and the path list will consist of the paths given in <i>paths</i>.</p>
 
316
<p>See also <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>(), <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>(), and <a href="qlibrary.html">QLibrary</a>.</p>
 
317
<h3 class="fn"><a name="startingUp"></a>bool QCoreApplication::startingUp ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
318
<p>Returns true if an application object has not been created yet; otherwise returns false.</p>
 
319
<p>See also <a href="qcoreapplication.html#closingDown">closingDown</a>().</p>
 
320
<h3 class="fn"><a name="translate"></a><a href="qstring.html">QString</a> QCoreApplication::translate ( const char * <i>context</i>, const char * <i>sourceText</i>, const char * <i>comment</i> = 0, <a href="qcoreapplication.html#Encoding-enum">Encoding</a> <i>encoding</i> = DefaultCodec )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
321
<p>Returns the translation text for <i>sourceText</i>, by querying the installed messages files. The message files are searched from the most recently installed message file back to the first installed message file.</p>
 
322
<p><a href="qobject.html#tr">QObject::tr</a>() and <a href="qobject.html#trUtf8">QObject::trUtf8</a>() provide this functionality more conveniently.</p>
 
323
<p><i>context</i> is typically a class name (e.g., &quot;MyDialog&quot;) and <i>sourceText</i> is either English text or a short identifying text, if the output text will be very long (as for help texts).</p>
 
324
<p><i>comment</i> is a disambiguating comment, for when the same <i>sourceText</i> is used in different roles within the same context. By default, it is null. <i>encoding</i> indicates the 8-bit encoding of character stings</p>
 
325
<p>See the <a href="qtranslator.html">QTranslator</a> documentation for more information about contexts and comments.</p>
 
326
<p>If none of the message files contain a translation for <i>sourceText</i> in <i>context</i>, this function returns a <a href="qstring.html">QString</a> equivalent of <i>sourceText</i>. The encoding of <i>sourceText</i> is specified by <i>encoding</i>; it defaults to <tt>DefaultCodec</tt>.</p>
 
327
<p>This function is not virtual. You can use alternative translation techniques by subclassing <a href="qtranslator.html">QTranslator</a>.</p>
 
328
<p><b>Warning:</b> This method is reentrant only if all translators are installed <i>before</i> calling this method. Installing or removing translators while performing translations is not supported. Doing so will most likely result in crashes or other undesirable behavior.</p>
 
329
<p><b>Note:</b> This function is <a href="threads.html#reentrant">reentrant</a>.</p>
 
330
<p>See also <a href="qobject.html#tr">QObject::tr</a>(), <a href="qcoreapplication.html#installTranslator">installTranslator</a>(), and <a href="qtextcodec.html#codecForTr">QTextCodec::codecForTr</a>().</p>
 
331
<h3 class="fn"><a name="unixSignal"></a>void QCoreApplication::unixSignal ( int <i>number</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
332
<p>This signal is emitted whenever a Unix signal is received by the application. The Unix signal received is specified by its <i>number</i>.</p>
 
333
<h3 class="fn"><a name="winEventFilter"></a>bool QCoreApplication::winEventFilter ( MSG * <i>msg</i>, long * <i>result</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
334
<p>The message procedure calls this function for every message received. Reimplement this function if you want to process window messages <i>msg</i> that are not processed by Qt. If you don't want the event to be processed by Qt, then return true and set <i>result</i> to the value that the window procedure should return. Otherwise return false.</p>
 
335
<hr />
 
336
<h2>Related Non-Members</h2>
 
337
<h3 class="fn"><a name="qAddPostRoutine"></a>void qAddPostRoutine ( QtCleanUpFunction <i>ptr</i> )</h3>
 
338
<p>Adds a global routine that will be called from the <a href="qapplication.html">QApplication</a> destructor. This function is normally used to add cleanup routines for program-wide functionality.</p>
 
339
<p>The function specified by <i>ptr</i> should take no arguments and should return nothing. For example:</p>
 
340
<pre>&nbsp;   static int *global_ptr = 0;
 
341
 
 
342
    static void cleanup_ptr()
 
343
    {
 
344
        delete [] global_ptr;
 
345
        global_ptr = 0;
 
346
    }
 
347
 
 
348
    void init_ptr()
 
349
    {
 
350
        global_ptr = new int[100];      // allocate data
 
351
        qAddPostRoutine(cleanup_ptr);   // delete later
 
352
    }</pre>
 
353
<p>Note that for an application- or module-wide cleanup, qAddPostRoutine() is often not suitable. For example, if the program is split into dynamically loaded modules, the relevant module may be unloaded long before the <a href="qapplication.html">QApplication</a> destructor is called.</p>
 
354
<p>For modules and libraries, using a reference-counted initialization manager or Qt's parent-child deletion mechanism may be better. Here is an example of a private class which uses the parent-child mechanism to call a cleanup function at the right time:</p>
 
355
<pre>&nbsp;   class MyPrivateInitStuff : public QObject
 
356
    {
 
357
    public:
 
358
        static MyPrivateInitStuff *initStuff(QObject *parent)
 
359
        {
 
360
            if (!p)
 
361
                p = new MyPrivateInitStuff(parent);
 
362
            return p;
 
363
        }
 
364
 
 
365
        ~MyPrivateInitStuff()
 
366
        {
 
367
            // cleanup goes here
 
368
        }
 
369
 
 
370
    private:
 
371
        MyPrivateInitStuff(QObject *parent)
 
372
            : QObject(parent)
 
373
        {
 
374
            // initialization goes here
 
375
        }
 
376
 
 
377
        MyPrivateInitStuff *p;
 
378
    };</pre>
 
379
<p>By selecting the right parent object, this can often be made to clean up the module's data at the exactly the right moment.</p>
 
380
<p /><address><hr /><div align="center">
 
381
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
382
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
383
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
384
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
385
</tr></table></div></address></body>
 
386
</html>