1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qapplication.cpp:76 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QApplication Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QApplication Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QApplication class manages the GUI application's control
|
---|
35 | flow and main settings.
|
---|
36 | <a href="#details">More...</a>
|
---|
37 | <p><tt>#include <<a href="qapplication-h.html">qapplication.h</a>></tt>
|
---|
38 | <p>Inherits <a href="qobject.html">QObject</a>.
|
---|
39 | <p><a href="qapplication-members.html">List of all member functions.</a>
|
---|
40 | <h2>Public Members</h2>
|
---|
41 | <ul>
|
---|
42 | <li class=fn><a href="#QApplication"><b>QApplication</b></a> ( int & argc, char ** argv )</li>
|
---|
43 | <li class=fn><a href="#QApplication-2"><b>QApplication</b></a> ( int & argc, char ** argv, bool GUIenabled )</li>
|
---|
44 | <li class=fn>enum <a href="#Type-enum"><b>Type</b></a> { Tty, GuiClient, GuiServer }</li>
|
---|
45 | <li class=fn><a href="#QApplication-3"><b>QApplication</b></a> ( int & argc, char ** argv, Type type )</li>
|
---|
46 | <li class=fn><a href="#QApplication-4"><b>QApplication</b></a> ( Display * dpy, HANDLE visual = 0, HANDLE colormap = 0 )</li>
|
---|
47 | <li class=fn><a href="#QApplication-5"><b>QApplication</b></a> ( Display * dpy, int argc, char ** argv, HANDLE visual = 0, HANDLE colormap = 0 )</li>
|
---|
48 | <li class=fn>virtual <a href="#~QApplication"><b>~QApplication</b></a> ()</li>
|
---|
49 | <li class=fn>int <a href="#argc"><b>argc</b></a> () const</li>
|
---|
50 | <li class=fn>char ** <a href="#argv"><b>argv</b></a> () const</li>
|
---|
51 | <li class=fn>Type <a href="#type"><b>type</b></a> () const</li>
|
---|
52 | <li class=fn>enum <a href="#ColorSpec-enum"><b>ColorSpec</b></a> { NormalColor = 0, CustomColor = 1, ManyColor = 2 }</li>
|
---|
53 | <li class=fn>QWidget * <a href="#mainWidget"><b>mainWidget</b></a> () const</li>
|
---|
54 | <li class=fn>virtual void <a href="#setMainWidget"><b>setMainWidget</b></a> ( QWidget * mainWidget )</li>
|
---|
55 | <li class=fn>virtual void <a href="#polish"><b>polish</b></a> ( QWidget * w )</li>
|
---|
56 | <li class=fn>QWidget * <a href="#focusWidget"><b>focusWidget</b></a> () const</li>
|
---|
57 | <li class=fn>QWidget * <a href="#activeWindow"><b>activeWindow</b></a> () const</li>
|
---|
58 | <li class=fn>int <a href="#exec"><b>exec</b></a> ()</li>
|
---|
59 | <li class=fn>void <a href="#processEvents"><b>processEvents</b></a> ()</li>
|
---|
60 | <li class=fn>void <a href="#processEvents-2"><b>processEvents</b></a> ( int maxtime )</li>
|
---|
61 | <li class=fn>void processOneEvent () <em>(obsolete)</em></li>
|
---|
62 | <li class=fn>bool <a href="#hasPendingEvents"><b>hasPendingEvents</b></a> ()</li>
|
---|
63 | <li class=fn>int enter_loop () <em>(obsolete)</em></li>
|
---|
64 | <li class=fn>void exit_loop () <em>(obsolete)</em></li>
|
---|
65 | <li class=fn>int loopLevel () const <em>(obsolete)</em></li>
|
---|
66 | <li class=fn>virtual bool <a href="#notify"><b>notify</b></a> ( QObject * receiver, QEvent * e )</li>
|
---|
67 | <li class=fn>void setDefaultCodec ( QTextCodec * codec ) <em>(obsolete)</em></li>
|
---|
68 | <li class=fn>QTextCodec * defaultCodec () const <em>(obsolete)</em></li>
|
---|
69 | <li class=fn>void <a href="#installTranslator"><b>installTranslator</b></a> ( QTranslator * mf )</li>
|
---|
70 | <li class=fn>void <a href="#removeTranslator"><b>removeTranslator</b></a> ( QTranslator * mf )</li>
|
---|
71 | <li class=fn>enum <a href="#Encoding-enum"><b>Encoding</b></a> { DefaultCodec, UnicodeUTF8 }</li>
|
---|
72 | <li class=fn>QString <a href="#translate"><b>translate</b></a> ( const char * context, const char * sourceText, const char * comment = 0, Encoding encoding = DefaultCodec ) const</li>
|
---|
73 | <li class=fn>QString <a href="#applicationDirPath"><b>applicationDirPath</b></a> ()</li>
|
---|
74 | <li class=fn>QString <a href="#applicationFilePath"><b>applicationFilePath</b></a> ()</li>
|
---|
75 | <li class=fn>virtual bool <a href="#macEventFilter"><b>macEventFilter</b></a> ( EventHandlerCallRef, EventRef )</li>
|
---|
76 | <li class=fn>virtual bool <a href="#winEventFilter"><b>winEventFilter</b></a> ( MSG * )</li>
|
---|
77 | <li class=fn>virtual bool <a href="#x11EventFilter"><b>x11EventFilter</b></a> ( XEvent * )</li>
|
---|
78 | <li class=fn>int <a href="#x11ProcessEvent"><b>x11ProcessEvent</b></a> ( XEvent * event )</li>
|
---|
79 | <li class=fn>virtual bool <a href="#qwsEventFilter"><b>qwsEventFilter</b></a> ( QWSEvent * )</li>
|
---|
80 | <li class=fn>void <a href="#qwsSetCustomColors"><b>qwsSetCustomColors</b></a> ( QRgb * colorTable, int start, int numColors )</li>
|
---|
81 | <li class=fn>void <a href="#winFocus"><b>winFocus</b></a> ( QWidget * widget, bool gotFocus )</li>
|
---|
82 | <li class=fn>bool <a href="#isSessionRestored"><b>isSessionRestored</b></a> () const</li>
|
---|
83 | <li class=fn>QString <a href="#sessionId"><b>sessionId</b></a> () const</li>
|
---|
84 | <li class=fn>QString <a href="#sessionKey"><b>sessionKey</b></a> () const</li>
|
---|
85 | <li class=fn>virtual void <a href="#commitData"><b>commitData</b></a> ( QSessionManager & sm )</li>
|
---|
86 | <li class=fn>virtual void <a href="#saveState"><b>saveState</b></a> ( QSessionManager & sm )</li>
|
---|
87 | <li class=fn>void <a href="#wakeUpGuiThread"><b>wakeUpGuiThread</b></a> ()</li>
|
---|
88 | <li class=fn>void <a href="#lock"><b>lock</b></a> ()</li>
|
---|
89 | <li class=fn>void <a href="#unlock"><b>unlock</b></a> ( bool wakeUpGui = TRUE )</li>
|
---|
90 | <li class=fn>bool <a href="#locked"><b>locked</b></a> ()</li>
|
---|
91 | <li class=fn>bool <a href="#tryLock"><b>tryLock</b></a> ()</li>
|
---|
92 | </ul>
|
---|
93 | <h2>Public Slots</h2>
|
---|
94 | <ul>
|
---|
95 | <li class=fn>void <a href="#quit"><b>quit</b></a> ()</li>
|
---|
96 | <li class=fn>void <a href="#closeAllWindows"><b>closeAllWindows</b></a> ()</li>
|
---|
97 | <li class=fn>void <a href="#aboutQt"><b>aboutQt</b></a> ()</li>
|
---|
98 | </ul>
|
---|
99 | <h2>Signals</h2>
|
---|
100 | <ul>
|
---|
101 | <li class=fn>void <a href="#lastWindowClosed"><b>lastWindowClosed</b></a> ()</li>
|
---|
102 | <li class=fn>void <a href="#aboutToQuit"><b>aboutToQuit</b></a> ()</li>
|
---|
103 | <li class=fn>void <a href="#guiThreadAwake"><b>guiThreadAwake</b></a> ()</li>
|
---|
104 | </ul>
|
---|
105 | <h2>Static Public Members</h2>
|
---|
106 | <ul>
|
---|
107 | <li class=fn>QStyle & <a href="#style"><b>style</b></a> ()</li>
|
---|
108 | <li class=fn>void <a href="#setStyle"><b>setStyle</b></a> ( QStyle * style )</li>
|
---|
109 | <li class=fn>QStyle * <a href="#setStyle-2"><b>setStyle</b></a> ( const QString & style )</li>
|
---|
110 | <li class=fn>int <a href="#colorSpec"><b>colorSpec</b></a> ()</li>
|
---|
111 | <li class=fn>void <a href="#setColorSpec"><b>setColorSpec</b></a> ( int spec )</li>
|
---|
112 | <li class=fn>QCursor * <a href="#overrideCursor"><b>overrideCursor</b></a> ()</li>
|
---|
113 | <li class=fn>void <a href="#setOverrideCursor"><b>setOverrideCursor</b></a> ( const QCursor & cursor, bool replace = FALSE )</li>
|
---|
114 | <li class=fn>void <a href="#restoreOverrideCursor"><b>restoreOverrideCursor</b></a> ()</li>
|
---|
115 | <li class=fn>bool <a href="#hasGlobalMouseTracking"><b>hasGlobalMouseTracking</b></a> ()</li>
|
---|
116 | <li class=fn>void <a href="#setGlobalMouseTracking"><b>setGlobalMouseTracking</b></a> ( bool enable )</li>
|
---|
117 | <li class=fn>QPalette <a href="#palette"><b>palette</b></a> ( const QWidget * w = 0 )</li>
|
---|
118 | <li class=fn>void <a href="#setPalette"><b>setPalette</b></a> ( const QPalette & palette, bool informWidgets = FALSE, const char * className = 0 )</li>
|
---|
119 | <li class=fn>QFont <a href="#font"><b>font</b></a> ( const QWidget * w = 0 )</li>
|
---|
120 | <li class=fn>void <a href="#setFont"><b>setFont</b></a> ( const QFont & font, bool informWidgets = FALSE, const char * className = 0 )</li>
|
---|
121 | <li class=fn>QFontMetrics <a href="#fontMetrics"><b>fontMetrics</b></a> ()</li>
|
---|
122 | <li class=fn>QWidgetList * <a href="#allWidgets"><b>allWidgets</b></a> ()</li>
|
---|
123 | <li class=fn>QWidgetList * <a href="#topLevelWidgets"><b>topLevelWidgets</b></a> ()</li>
|
---|
124 | <li class=fn>QDesktopWidget * <a href="#desktop"><b>desktop</b></a> ()</li>
|
---|
125 | <li class=fn>QWidget * <a href="#activePopupWidget"><b>activePopupWidget</b></a> ()</li>
|
---|
126 | <li class=fn>QWidget * <a href="#activeModalWidget"><b>activeModalWidget</b></a> ()</li>
|
---|
127 | <li class=fn>QClipboard * <a href="#clipboard"><b>clipboard</b></a> ()</li>
|
---|
128 | <li class=fn>QWidget * <a href="#widgetAt"><b>widgetAt</b></a> ( int x, int y, bool child = FALSE )</li>
|
---|
129 | <li class=fn>QWidget * <a href="#widgetAt-2"><b>widgetAt</b></a> ( const QPoint & pos, bool child = FALSE )</li>
|
---|
130 | <li class=fn>QEventLoop * <a href="#eventLoop"><b>eventLoop</b></a> ()</li>
|
---|
131 | <li class=fn>void <a href="#exit"><b>exit</b></a> ( int retcode = 0 )</li>
|
---|
132 | <li class=fn>bool <a href="#sendEvent"><b>sendEvent</b></a> ( QObject * receiver, QEvent * event )</li>
|
---|
133 | <li class=fn>void <a href="#postEvent"><b>postEvent</b></a> ( QObject * receiver, QEvent * event )</li>
|
---|
134 | <li class=fn>void <a href="#sendPostedEvents"><b>sendPostedEvents</b></a> ( QObject * receiver, int event_type )</li>
|
---|
135 | <li class=fn>void <a href="#sendPostedEvents-2"><b>sendPostedEvents</b></a> ()</li>
|
---|
136 | <li class=fn>void <a href="#removePostedEvents"><b>removePostedEvents</b></a> ( QObject * receiver )</li>
|
---|
137 | <li class=fn>bool <a href="#startingUp"><b>startingUp</b></a> ()</li>
|
---|
138 | <li class=fn>bool <a href="#closingDown"><b>closingDown</b></a> ()</li>
|
---|
139 | <li class=fn>void <a href="#flushX"><b>flushX</b></a> ()</li>
|
---|
140 | <li class=fn>void <a href="#flush"><b>flush</b></a> ()</li>
|
---|
141 | <li class=fn>void <a href="#syncX"><b>syncX</b></a> ()</li>
|
---|
142 | <li class=fn>void <a href="#beep"><b>beep</b></a> ()</li>
|
---|
143 | <li class=fn>void setWinStyleHighlightColor ( const QColor & c ) <em>(obsolete)</em></li>
|
---|
144 | <li class=fn>const QColor & winStyleHighlightColor () <em>(obsolete)</em></li>
|
---|
145 | <li class=fn>void <a href="#setDesktopSettingsAware"><b>setDesktopSettingsAware</b></a> ( bool on )</li>
|
---|
146 | <li class=fn>bool <a href="#desktopSettingsAware"><b>desktopSettingsAware</b></a> ()</li>
|
---|
147 | <li class=fn>void <a href="#setCursorFlashTime"><b>setCursorFlashTime</b></a> ( int msecs )</li>
|
---|
148 | <li class=fn>int <a href="#cursorFlashTime"><b>cursorFlashTime</b></a> ()</li>
|
---|
149 | <li class=fn>void <a href="#setDoubleClickInterval"><b>setDoubleClickInterval</b></a> ( int ms )</li>
|
---|
150 | <li class=fn>int <a href="#doubleClickInterval"><b>doubleClickInterval</b></a> ()</li>
|
---|
151 | <li class=fn>void <a href="#setWheelScrollLines"><b>setWheelScrollLines</b></a> ( int n )</li>
|
---|
152 | <li class=fn>int <a href="#wheelScrollLines"><b>wheelScrollLines</b></a> ()</li>
|
---|
153 | <li class=fn>void <a href="#setGlobalStrut"><b>setGlobalStrut</b></a> ( const QSize & strut )</li>
|
---|
154 | <li class=fn>QSize <a href="#globalStrut"><b>globalStrut</b></a> ()</li>
|
---|
155 | <li class=fn>void <a href="#setLibraryPaths"><b>setLibraryPaths</b></a> ( const QStringList & paths )</li>
|
---|
156 | <li class=fn>QStringList <a href="#libraryPaths"><b>libraryPaths</b></a> ()</li>
|
---|
157 | <li class=fn>void <a href="#addLibraryPath"><b>addLibraryPath</b></a> ( const QString & path )</li>
|
---|
158 | <li class=fn>void <a href="#removeLibraryPath"><b>removeLibraryPath</b></a> ( const QString & path )</li>
|
---|
159 | <li class=fn>void <a href="#setStartDragTime"><b>setStartDragTime</b></a> ( int ms )</li>
|
---|
160 | <li class=fn>int <a href="#startDragTime"><b>startDragTime</b></a> ()</li>
|
---|
161 | <li class=fn>void <a href="#setStartDragDistance"><b>setStartDragDistance</b></a> ( int l )</li>
|
---|
162 | <li class=fn>int <a href="#startDragDistance"><b>startDragDistance</b></a> ()</li>
|
---|
163 | <li class=fn>void <a href="#setReverseLayout"><b>setReverseLayout</b></a> ( bool b )</li>
|
---|
164 | <li class=fn>bool <a href="#reverseLayout"><b>reverseLayout</b></a> ()</li>
|
---|
165 | <li class=fn>int <a href="#horizontalAlignment"><b>horizontalAlignment</b></a> ( int align )</li>
|
---|
166 | <li class=fn>bool <a href="#isEffectEnabled"><b>isEffectEnabled</b></a> ( Qt::UIEffect effect )</li>
|
---|
167 | <li class=fn>void <a href="#setEffectEnabled"><b>setEffectEnabled</b></a> ( Qt::UIEffect effect, bool enable = TRUE )</li>
|
---|
168 | <li class=fn>QWSDecoration & <a href="#qwsDecoration"><b>qwsDecoration</b></a> ()</li>
|
---|
169 | <li class=fn>void <a href="#qwsSetDecoration"><b>qwsSetDecoration</b></a> ( QWSDecoration * d )</li>
|
---|
170 | </ul>
|
---|
171 | <h2>Related Functions</h2>
|
---|
172 | <ul>
|
---|
173 | <li class=fn>void <a href="#qAddPostRoutine"><b>qAddPostRoutine</b></a> ( QtCleanUpFunction p )</li>
|
---|
174 | <li class=fn>const char * <a href="#qVersion"><b>qVersion</b></a> ()</li>
|
---|
175 | <li class=fn>bool <a href="#qSysInfo"><b>qSysInfo</b></a> ( int * wordSize, bool * bigEndian )</li>
|
---|
176 | <li class=fn>void <a href="#qDebug"><b>qDebug</b></a> ( const char * msg, ... )</li>
|
---|
177 | <li class=fn>void <a href="#qWarning"><b>qWarning</b></a> ( const char * msg, ... )</li>
|
---|
178 | <li class=fn>void <a href="#qFatal"><b>qFatal</b></a> ( const char * msg, ... )</li>
|
---|
179 | <li class=fn>void <a href="#qSystemWarning"><b>qSystemWarning</b></a> ( const char * msg, int code )</li>
|
---|
180 | <li class=fn>void <a href="#Q_ASSERT"><b>Q_ASSERT</b></a> ( bool test )</li>
|
---|
181 | <li class=fn>void <a href="#Q_CHECK_PTR"><b>Q_CHECK_PTR</b></a> ( void * p )</li>
|
---|
182 | <li class=fn>QtMsgHandler <a href="#qInstallMsgHandler"><b>qInstallMsgHandler</b></a> ( QtMsgHandler h )</li>
|
---|
183 | </ul>
|
---|
184 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
185 |
|
---|
186 |
|
---|
187 | The QApplication class manages the GUI application's control
|
---|
188 | flow and main settings.
|
---|
189 | <p>
|
---|
190 |
|
---|
191 | <p> It contains the main event loop, where all events from the window
|
---|
192 | system and other sources are processed and dispatched. It also
|
---|
193 | handles the application's initialization and finalization, and
|
---|
194 | provides session management. It also handles most system-wide and
|
---|
195 | application-wide settings.
|
---|
196 | <p> For any GUI application that uses Qt, there is precisely one
|
---|
197 | QApplication object, no matter whether the application has 0, 1, 2
|
---|
198 | or more windows at any time.
|
---|
199 | <p> The QApplication object is accessible through the global pointer <tt>qApp</tt>. Its main areas of responsibility are:
|
---|
200 | <ul>
|
---|
201 | <p> <li> It initializes the application with the user's desktop settings
|
---|
202 | such as <a href="#palette">palette</a>(), <a href="#font">font</a>() and <a href="#doubleClickInterval">doubleClickInterval</a>(). It keeps track
|
---|
203 | of these properties in case the user changes the desktop globally, for
|
---|
204 | example through some kind of control panel.
|
---|
205 | <p> <li> It performs event handling, meaning that it receives events
|
---|
206 | from the underlying window system and dispatches them to the relevant
|
---|
207 | widgets. By using <a href="#sendEvent">sendEvent</a>() and <a href="#postEvent">postEvent</a>() you can send your own
|
---|
208 | events to widgets.
|
---|
209 | <p> <li> It parses common command line arguments and sets its internal
|
---|
210 | state accordingly. See the <a href="#QApplication">constructor documentation</a> below for more details about this.
|
---|
211 | <p> <li> It defines the application's look and feel, which is
|
---|
212 | encapsulated in a <a href="qstyle.html">QStyle</a> object. This can be changed at runtime
|
---|
213 | with <a href="#setStyle">setStyle</a>().
|
---|
214 | <p> <li> It specifies how the application is to allocate colors.
|
---|
215 | See <a href="#setColorSpec">setColorSpec</a>() for details.
|
---|
216 | <p> <li> It provides <a href="i18n.html#localization">localization</a> of strings that are visible to the user
|
---|
217 | via <a href="#translate">translate</a>().
|
---|
218 | <p> <li> It provides some magical objects like the <a href="#desktop">desktop</a>() and the
|
---|
219 | <a href="#clipboard">clipboard</a>().
|
---|
220 | <p> <li> It knows about the application's windows. You can ask which
|
---|
221 | widget is at a certain position using <a href="#widgetAt">widgetAt</a>(), get a list of
|
---|
222 | <a href="#topLevelWidgets">topLevelWidgets</a>() and <a href="#closeAllWindows">closeAllWindows</a>(), etc.
|
---|
223 | <p> <li> It manages the application's mouse cursor handling,
|
---|
224 | see <a href="#setOverrideCursor">setOverrideCursor</a>() and <a href="#setGlobalMouseTracking">setGlobalMouseTracking</a>().
|
---|
225 | <p> <li> On the X window system, it provides functions to flush and sync
|
---|
226 | the communication stream, see <a href="#flushX">flushX</a>() and <a href="#syncX">syncX</a>().
|
---|
227 | <p> <li> It provides support for sophisticated <a href="session.html">session management</a>. This makes it possible
|
---|
228 | for applications to terminate gracefully when the user logs out, to
|
---|
229 | cancel a shutdown process if termination isn't possible and even to
|
---|
230 | preserve the entire application's state for a future session. See
|
---|
231 | <a href="#isSessionRestored">isSessionRestored</a>(), <a href="#sessionId">sessionId</a>() and <a href="#commitData">commitData</a>() and <a href="#saveState">saveState</a>()
|
---|
232 | for details.
|
---|
233 | <p> </ul>
|
---|
234 | <p> The <a href="simple-application.html">Application walk-through
|
---|
235 | example</a> contains a typical complete main() that does the usual
|
---|
236 | things with QApplication.
|
---|
237 | <p> Since the QApplication object does so much initialization, it
|
---|
238 | <b>must</b> be created before any other objects related to the user
|
---|
239 | interface are created.
|
---|
240 | <p> Since it also deals with common command line arguments, it is
|
---|
241 | usually a good idea to create it <em>before</em> any interpretation or
|
---|
242 | modification of <tt>argv</tt> is done in the application itself. (Note
|
---|
243 | also that for X11, <a href="#setMainWidget">setMainWidget</a>() may change the main widget
|
---|
244 | according to the <tt>-geometry</tt> option. To preserve this
|
---|
245 | functionality, you must set your defaults before setMainWidget() and
|
---|
246 | any overrides after.)
|
---|
247 | <p> <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
248 | <tr bgcolor="#a2c511"> <th valign="top" colspan="2" rowspan="1"> Groups of functions
|
---|
249 | <tr bgcolor="#f0f0f0">
|
---|
250 | <td valign="top">System settings
|
---|
251 | <td valign="top">
|
---|
252 | <a href="#desktopSettingsAware">desktopSettingsAware</a>(),
|
---|
253 | <a href="#setDesktopSettingsAware">setDesktopSettingsAware</a>(),
|
---|
254 | <a href="#cursorFlashTime">cursorFlashTime</a>(),
|
---|
255 | <a href="#setCursorFlashTime">setCursorFlashTime</a>(),
|
---|
256 | <a href="#doubleClickInterval">doubleClickInterval</a>(),
|
---|
257 | <a href="#setDoubleClickInterval">setDoubleClickInterval</a>(),
|
---|
258 | <a href="#wheelScrollLines">wheelScrollLines</a>(),
|
---|
259 | <a href="#setWheelScrollLines">setWheelScrollLines</a>(),
|
---|
260 | <a href="#palette">palette</a>(),
|
---|
261 | <a href="#setPalette">setPalette</a>(),
|
---|
262 | <a href="#font">font</a>(),
|
---|
263 | <a href="#setFont">setFont</a>(),
|
---|
264 | <a href="#fontMetrics">fontMetrics</a>().
|
---|
265 | <tr bgcolor="#d0d0d0">
|
---|
266 | <td valign="top">Event handling
|
---|
267 | <td valign="top">
|
---|
268 | <a href="#exec">exec</a>(),
|
---|
269 | <a href="#processEvents">processEvents</a>(),
|
---|
270 | <a href="#enter_loop">enter_loop</a>(),
|
---|
271 | <a href="#exit_loop">exit_loop</a>(),
|
---|
272 | <a href="#exit">exit</a>(),
|
---|
273 | <a href="#quit">quit</a>().
|
---|
274 | <a href="#sendEvent">sendEvent</a>(),
|
---|
275 | <a href="#postEvent">postEvent</a>(),
|
---|
276 | <a href="#sendPostedEvents">sendPostedEvents</a>(),
|
---|
277 | <a href="#removePostedEvents">removePostedEvents</a>(),
|
---|
278 | <a href="#hasPendingEvents">hasPendingEvents</a>(),
|
---|
279 | <a href="#notify">notify</a>(),
|
---|
280 | <a href="#macEventFilter">macEventFilter</a>(),
|
---|
281 | <a href="#qwsEventFilter">qwsEventFilter</a>(),
|
---|
282 | <a href="#x11EventFilter">x11EventFilter</a>(),
|
---|
283 | <a href="#x11ProcessEvent">x11ProcessEvent</a>(),
|
---|
284 | <a href="#winEventFilter">winEventFilter</a>().
|
---|
285 | <tr bgcolor="#f0f0f0">
|
---|
286 | <td valign="top">GUI Styles
|
---|
287 | <td valign="top">
|
---|
288 | <a href="#style">style</a>(),
|
---|
289 | <a href="#setStyle">setStyle</a>(),
|
---|
290 | <a href="#polish">polish</a>().
|
---|
291 | <tr bgcolor="#d0d0d0">
|
---|
292 | <td valign="top">Color usage
|
---|
293 | <td valign="top">
|
---|
294 | <a href="#colorSpec">colorSpec</a>(),
|
---|
295 | <a href="#setColorSpec">setColorSpec</a>(),
|
---|
296 | <a href="#qwsSetCustomColors">qwsSetCustomColors</a>().
|
---|
297 | <tr bgcolor="#f0f0f0">
|
---|
298 | <td valign="top">Text handling
|
---|
299 | <td valign="top">
|
---|
300 | <a href="#installTranslator">installTranslator</a>(),
|
---|
301 | <a href="#removeTranslator">removeTranslator</a>()
|
---|
302 | <a href="#translate">translate</a>().
|
---|
303 | <tr bgcolor="#d0d0d0">
|
---|
304 | <td valign="top">Widgets
|
---|
305 | <td valign="top">
|
---|
306 | <a href="#mainWidget">mainWidget</a>(),
|
---|
307 | <a href="#setMainWidget">setMainWidget</a>(),
|
---|
308 | <a href="#allWidgets">allWidgets</a>(),
|
---|
309 | <a href="#topLevelWidgets">topLevelWidgets</a>(),
|
---|
310 | <a href="#desktop">desktop</a>(),
|
---|
311 | <a href="#activePopupWidget">activePopupWidget</a>(),
|
---|
312 | <a href="#activeModalWidget">activeModalWidget</a>(),
|
---|
313 | <a href="#clipboard">clipboard</a>(),
|
---|
314 | <a href="#focusWidget">focusWidget</a>(),
|
---|
315 | <a href="#winFocus">winFocus</a>(),
|
---|
316 | <a href="#activeWindow">activeWindow</a>(),
|
---|
317 | <a href="#widgetAt">widgetAt</a>().
|
---|
318 | <tr bgcolor="#f0f0f0">
|
---|
319 | <td valign="top">Advanced cursor handling
|
---|
320 | <td valign="top">
|
---|
321 | <a href="#hasGlobalMouseTracking">hasGlobalMouseTracking</a>(),
|
---|
322 | <a href="#setGlobalMouseTracking">setGlobalMouseTracking</a>(),
|
---|
323 | <a href="#overrideCursor">overrideCursor</a>(),
|
---|
324 | <a href="#setOverrideCursor">setOverrideCursor</a>(),
|
---|
325 | <a href="#restoreOverrideCursor">restoreOverrideCursor</a>().
|
---|
326 | <tr bgcolor="#d0d0d0">
|
---|
327 | <td valign="top">X Window System synchronization
|
---|
328 | <td valign="top">
|
---|
329 | <a href="#flushX">flushX</a>(),
|
---|
330 | <a href="#syncX">syncX</a>().
|
---|
331 | <tr bgcolor="#f0f0f0">
|
---|
332 | <td valign="top">Session management
|
---|
333 | <td valign="top">
|
---|
334 | <a href="#isSessionRestored">isSessionRestored</a>(),
|
---|
335 | <a href="#sessionId">sessionId</a>(),
|
---|
336 | <a href="#commitData">commitData</a>(),
|
---|
337 | <a href="#saveState">saveState</a>().
|
---|
338 | <tr bgcolor="#d0d0d0">
|
---|
339 | <td valign="top">Threading
|
---|
340 | <td valign="top">
|
---|
341 | <a href="#lock">lock</a>(), <a href="#unlock">unlock</a>(), <a href="#locked">locked</a>(), <a href="#tryLock">tryLock</a>(),
|
---|
342 | <a href="#wakeUpGuiThread">wakeUpGuiThread</a>()
|
---|
343 | <tr bgcolor="#f0f0f0">
|
---|
344 | <td valign="top">Miscellaneous
|
---|
345 | <td valign="top">
|
---|
346 | <a href="#closeAllWindows">closeAllWindows</a>(),
|
---|
347 | <a href="#startingUp">startingUp</a>(),
|
---|
348 | <a href="#closingDown">closingDown</a>(),
|
---|
349 | <a href="#type">type</a>().
|
---|
350 | </table></center>
|
---|
351 | <p> <em>Non-GUI programs:</em> While Qt is not optimized or
|
---|
352 | designed for writing non-GUI programs, it's possible to use
|
---|
353 | <a href="tools.html">some of its classes</a> without creating a
|
---|
354 | QApplication. This can be useful if you wish to share code between
|
---|
355 | a non-GUI server and a GUI client.
|
---|
356 |
|
---|
357 |
|
---|
358 |
|
---|
359 | <p>See also <a href="application.html">Main Window and Related Classes</a>.
|
---|
360 |
|
---|
361 | <hr><h2>Member Type Documentation</h2>
|
---|
362 | <h3 class=fn><a name="ColorSpec-enum"></a>QApplication::ColorSpec</h3>
|
---|
363 |
|
---|
364 | <ul>
|
---|
365 | <li><tt>QApplication::NormalColor</tt> - the default color allocation policy
|
---|
366 | <li><tt>QApplication::CustomColor</tt> - the same as NormalColor for X11; allocates colors
|
---|
367 | to a palette on demand under Windows
|
---|
368 | <li><tt>QApplication::ManyColor</tt> - the right choice for applications that use thousands of
|
---|
369 | colors
|
---|
370 | </ul><p> See <a href="#setColorSpec">setColorSpec</a>() for full details.
|
---|
371 |
|
---|
372 | <h3 class=fn><a name="Encoding-enum"></a>QApplication::Encoding</h3>
|
---|
373 | <p> This enum type defines the 8-bit encoding of character string
|
---|
374 | arguments to <a href="#translate">translate</a>():
|
---|
375 | <ul>
|
---|
376 | <li><tt>QApplication::DefaultCodec</tt> - the encoding specified by
|
---|
377 | <a href="qtextcodec.html#codecForTr">QTextCodec::codecForTr</a>() (Latin-1 if none has been set)
|
---|
378 | <li><tt>QApplication::UnicodeUTF8</tt> - UTF-8
|
---|
379 | </ul><p> <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>().
|
---|
380 |
|
---|
381 | <h3 class=fn><a name="Type-enum"></a>QApplication::Type</h3>
|
---|
382 |
|
---|
383 | <ul>
|
---|
384 | <li><tt>QApplication::Tty</tt> - a console application
|
---|
385 | <li><tt>QApplication::GuiClient</tt> - a GUI client application
|
---|
386 | <li><tt>QApplication::GuiServer</tt> - a GUI server application
|
---|
387 | </ul>
|
---|
388 | <hr><h2>Member Function Documentation</h2>
|
---|
389 | <h3 class=fn><a name="QApplication"></a>QApplication::QApplication ( int & argc, char ** argv )
|
---|
390 | </h3>
|
---|
391 | Initializes the window system and constructs an application object
|
---|
392 | with <em>argc</em> command line arguments in <em>argv</em>.
|
---|
393 | <p> The global <tt>qApp</tt> pointer refers to this application object. Only
|
---|
394 | one application object should be created.
|
---|
395 | <p> This application object must be constructed before any <a href="qpaintdevice.html">paint devices</a> (including widgets, pixmaps, bitmaps
|
---|
396 | etc.).
|
---|
397 | <p> Note that <em>argc</em> and <em>argv</em> might be changed. Qt removes command
|
---|
398 | line arguments that it recognizes. The modified <em>argc</em> and <em>argv</em>
|
---|
399 | can also be accessed later with <tt>qApp->argc()</tt> and <tt>qApp->argv()</tt>.
|
---|
400 | The documentation for <a href="#argv">argv</a>() contains a detailed description of how
|
---|
401 | to process command line arguments.
|
---|
402 | <p> Qt debugging options (not available if Qt was compiled with the
|
---|
403 | QT_NO_DEBUG flag defined):
|
---|
404 | <ul>
|
---|
405 | <li> -nograb, tells Qt that it must never grab the mouse or the keyboard.
|
---|
406 | <li> -dograb (only under X11), running under a debugger can cause
|
---|
407 | an implicit -nograb, use -dograb to override.
|
---|
408 | <li> -sync (only under X11), switches to synchronous mode for
|
---|
409 | debugging.
|
---|
410 | </ul>
|
---|
411 | <p> See <a href="debug.html">Debugging Techniques</a> for a more
|
---|
412 | detailed explanation.
|
---|
413 | <p> All Qt programs automatically support the following command line options:
|
---|
414 | <ul>
|
---|
415 | <li> -reverse causes text to be formatted for right-to-left languages
|
---|
416 | rather than in the usual left-to-right direction.
|
---|
417 | <li> -style= <em>style</em>, sets the application GUI style. Possible values
|
---|
418 | are <tt>motif</tt>, <tt>windows</tt>, and <tt>platinum</tt>. If you compiled Qt
|
---|
419 | with additional styles or have additional styles as plugins these
|
---|
420 | will be available to the <tt>-style</tt> command line option.
|
---|
421 | <li> -style <em>style</em>, is the same as listed above.
|
---|
422 | <li> -session= <em>session</em>, restores the application from an earlier
|
---|
423 | <a href="session.html">session</a>.
|
---|
424 | <li> -session <em>session</em>, is the same as listed above.
|
---|
425 | <li> -widgetcount, prints debug message at the end about number of widgets left
|
---|
426 | undestroyed and maximum number of widgets existed at the same time
|
---|
427 | </ul>
|
---|
428 | <p> The X11 version of Qt also supports some traditional X11
|
---|
429 | command line options:
|
---|
430 | <ul>
|
---|
431 | <li> -display <em>display</em>, sets the X display (default is $DISPLAY).
|
---|
432 | <li> -geometry <em>geometry</em>, sets the client geometry of the
|
---|
433 | <a href="#setMainWidget">main widget</a>.
|
---|
434 | <li> -fn or <tt>-font</tt> <em>font</em>, defines the application font. The
|
---|
435 | font should be specified using an X logical font description.
|
---|
436 | <li> -bg or <tt>-background</tt> <em>color</em>, sets the default background color
|
---|
437 | and an application palette (light and dark shades are calculated).
|
---|
438 | <li> -fg or <tt>-foreground</tt> <em>color</em>, sets the default foreground color.
|
---|
439 | <li> -btn or <tt>-button</tt> <em>color</em>, sets the default button color.
|
---|
440 | <li> -name <em>name</em>, sets the application name.
|
---|
441 | <li> -title <em>title</em>, sets the application title (caption).
|
---|
442 | <li> -visual <tt>TrueColor</tt>, forces the application to use a TrueColor visual
|
---|
443 | on an 8-bit display.
|
---|
444 | <li> -ncols <em>count</em>, limits the number of colors allocated in the
|
---|
445 | color cube on an 8-bit display, if the application is using the
|
---|
446 | <a href="#ColorSpec-enum">QApplication::ManyColor</a> color specification. If <em>count</em> is
|
---|
447 | 216 then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green,
|
---|
448 | and 6 of blue); for other values, a cube
|
---|
449 | approximately proportional to a 2x3x1 cube is used.
|
---|
450 | <li> -cmap, causes the application to install a private color map
|
---|
451 | on an 8-bit display.
|
---|
452 | </ul>
|
---|
453 | <p> <p>See also <a href="#argc">argc</a>() and <a href="#argv">argv</a>().
|
---|
454 |
|
---|
455 | <h3 class=fn><a name="QApplication-2"></a>QApplication::QApplication ( int & argc, char ** argv, bool GUIenabled )
|
---|
456 | </h3>
|
---|
457 | Constructs an application object with <em>argc</em> command line arguments
|
---|
458 | in <em>argv</em>. If <em>GUIenabled</em> is TRUE, a GUI application is
|
---|
459 | constructed, otherwise a non-GUI (console) application is created.
|
---|
460 | <p> Set <em>GUIenabled</em> to FALSE for programs without a graphical user
|
---|
461 | interface that should be able to run without a window system.
|
---|
462 | <p> On X11, the window system is initialized if <em>GUIenabled</em> is TRUE.
|
---|
463 | If <em>GUIenabled</em> is FALSE, the application does not connect to the
|
---|
464 | X-server.
|
---|
465 | On Windows and Macintosh, currently the window system is always
|
---|
466 | initialized, regardless of the value of GUIenabled. This may change in
|
---|
467 | future versions of Qt.
|
---|
468 | <p> The following example shows how to create an application that
|
---|
469 | uses a graphical interface when available.
|
---|
470 | <pre>
|
---|
471 | int main( int argc, char **argv )
|
---|
472 | {
|
---|
473 | #ifdef Q_WS_X11
|
---|
474 | bool useGUI = getenv( "DISPLAY" ) != 0;
|
---|
475 | #else
|
---|
476 | bool useGUI = TRUE;
|
---|
477 | #endif
|
---|
478 | QApplication app(argc, argv, useGUI);
|
---|
479 |
|
---|
480 | if ( useGUI ) {
|
---|
481 | //start GUI version
|
---|
482 | ...
|
---|
483 | } else {
|
---|
484 | //start non-GUI version
|
---|
485 | ...
|
---|
486 | }
|
---|
487 | return app.<a href="#exec">exec</a>();
|
---|
488 | }
|
---|
489 | </pre>
|
---|
490 |
|
---|
491 |
|
---|
492 | <h3 class=fn><a name="QApplication-3"></a>QApplication::QApplication ( int & argc, char ** argv, <a href="qapplication.html#Type-enum">Type</a> type )
|
---|
493 | </h3>
|
---|
494 | Constructs an application object with <em>argc</em> command line arguments
|
---|
495 | in <em>argv</em>.
|
---|
496 | <p> For Qt/Embedded, passing <a href="#Type-enum">QApplication::GuiServer</a> for <em>type</em>
|
---|
497 | makes this application the server (equivalent to running with the
|
---|
498 | -qws option).
|
---|
499 |
|
---|
500 | <h3 class=fn><a name="QApplication-4"></a>QApplication::QApplication ( Display * dpy, HANDLE visual = 0, HANDLE colormap = 0 )
|
---|
501 | </h3>
|
---|
502 | Create an application, given an already open display <em>dpy</em>. If <em>visual</em> and <em>colormap</em> are non-zero, the application will use those as
|
---|
503 | the default Visual and Colormap contexts.
|
---|
504 | <p> <b>Warning:</b> Qt only supports TrueColor visuals at depths higher than 8
|
---|
505 | bits-per-pixel.
|
---|
506 | <p> This is available only on X11.
|
---|
507 |
|
---|
508 | <h3 class=fn><a name="QApplication-5"></a>QApplication::QApplication ( Display * dpy, int argc, char ** argv, HANDLE visual = 0, HANDLE colormap = 0 )
|
---|
509 | </h3>
|
---|
510 | Create an application, given an already open display <em>dpy</em> and using
|
---|
511 | <em>argc</em> command line arguments in <em>argv</em>. If <em>visual</em> and <em>colormap</em> are non-zero, the application will use those as
|
---|
512 | the default Visual and Colormap contexts.
|
---|
513 | <p> <b>Warning:</b> Qt only supports TrueColor visuals at depths higher than 8
|
---|
514 | bits-per-pixel.
|
---|
515 | <p> This is available only on X11.
|
---|
516 | <p>
|
---|
517 | <h3 class=fn><a name="~QApplication"></a>QApplication::~QApplication ()<tt> [virtual]</tt>
|
---|
518 | </h3>
|
---|
519 | Cleans up any window system resources that were allocated by this
|
---|
520 | application. Sets the global variable <tt>qApp</tt> to 0.
|
---|
521 |
|
---|
522 | <h3 class=fn>void <a name="aboutQt"></a>QApplication::aboutQt ()<tt> [slot]</tt>
|
---|
523 | </h3>
|
---|
524 | Displays a simple message box about Qt. The message includes the
|
---|
525 | version number of Qt being used by the application.
|
---|
526 | <p> This is useful for inclusion in the Help menu of an application.
|
---|
527 | See the examples/menu/menu.cpp example.
|
---|
528 | <p> This function is a convenience slot for <a href="qmessagebox.html#aboutQt">QMessageBox::aboutQt</a>().
|
---|
529 |
|
---|
530 | <h3 class=fn>void <a name="aboutToQuit"></a>QApplication::aboutToQuit ()<tt> [signal]</tt>
|
---|
531 | </h3>
|
---|
532 |
|
---|
533 | <p> This signal is emitted when the application is about to quit the
|
---|
534 | main event loop, e.g. when the event loop level drops to zero.
|
---|
535 | This may happen either after a call to <a href="#quit">quit</a>() from inside the
|
---|
536 | application or when the users shuts down the entire desktop session.
|
---|
537 | <p> The signal is particularly useful if your application has to do some
|
---|
538 | last-second cleanup. Note that no user interaction is possible in
|
---|
539 | this state.
|
---|
540 | <p> <p>See also <a href="#quit">quit</a>().
|
---|
541 |
|
---|
542 | <h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="activeModalWidget"></a>QApplication::activeModalWidget ()<tt> [static]</tt>
|
---|
543 | </h3>
|
---|
544 | Returns the active modal widget.
|
---|
545 | <p> A modal widget is a special top level widget which is a subclass of
|
---|
546 | <a href="qdialog.html">QDialog</a> that specifies the modal parameter of the constructor as
|
---|
547 | TRUE. A modal widget must be closed before the user can continue
|
---|
548 | with other parts of the program.
|
---|
549 | <p> Modal widgets are organized in a stack. This function returns
|
---|
550 | the active modal widget at the top of the stack.
|
---|
551 | <p> <p>See also <a href="#activePopupWidget">activePopupWidget</a>() and <a href="#topLevelWidgets">topLevelWidgets</a>().
|
---|
552 |
|
---|
553 | <h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="activePopupWidget"></a>QApplication::activePopupWidget ()<tt> [static]</tt>
|
---|
554 | </h3>
|
---|
555 | Returns the active popup widget.
|
---|
556 | <p> A popup widget is a special top level widget that sets the <a href="qt.html#WidgetFlags-enum">WType_Popup</a> widget flag, e.g. the <a href="qpopupmenu.html">QPopupMenu</a> widget. When the
|
---|
557 | application opens a popup widget, all events are sent to the popup.
|
---|
558 | Normal widgets and modal widgets cannot be accessed before the popup
|
---|
559 | widget is closed.
|
---|
560 | <p> Only other popup widgets may be opened when a popup widget is shown.
|
---|
561 | The popup widgets are organized in a stack. This function returns
|
---|
562 | the active popup widget at the top of the stack.
|
---|
563 | <p> <p>See also <a href="#activeModalWidget">activeModalWidget</a>() and <a href="#topLevelWidgets">topLevelWidgets</a>().
|
---|
564 |
|
---|
565 | <h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="activeWindow"></a>QApplication::activeWindow () const
|
---|
566 | </h3>
|
---|
567 |
|
---|
568 | <p> Returns the application top-level window that has the keyboard input
|
---|
569 | focus, or 0 if no application window has the focus. Note that
|
---|
570 | there might be an <a href="#activeWindow">activeWindow</a>() even if there is no <a href="#focusWidget">focusWidget</a>(),
|
---|
571 | for example if no widget in that window accepts key events.
|
---|
572 | <p> <p>See also <a href="qwidget.html#setFocus">QWidget::setFocus</a>(), <a href="qwidget.html#focus-prop">QWidget::focus</a>, and <a href="#focusWidget">focusWidget</a>().
|
---|
573 |
|
---|
574 | <p>Example: <a href="mail-example.html#x704">network/mail/smtp.cpp</a>.
|
---|
575 | <h3 class=fn>void <a name="addLibraryPath"></a>QApplication::addLibraryPath ( const <a href="qstring.html">QString</a> & path )<tt> [static]</tt>
|
---|
576 | </h3>
|
---|
577 | Append <em>path</em> to the end of the library path list. If <em>path</em> is
|
---|
578 | empty or already in the path list, the path list is not changed.
|
---|
579 | <p> The default path list consists of a single entry, the installation
|
---|
580 | directory for plugins. The default installation directory for plugins
|
---|
581 | is <tt>INSTALL/plugins</tt>, where <tt>INSTALL</tt> is the directory where Qt was
|
---|
582 | installed.
|
---|
583 | <p> <p>See also <a href="#removeLibraryPath">removeLibraryPath</a>(), <a href="#libraryPaths">libraryPaths</a>(), and <a href="#setLibraryPaths">setLibraryPaths</a>().
|
---|
584 |
|
---|
585 | <h3 class=fn>QWidgetList * <a name="allWidgets"></a>QApplication::allWidgets ()<tt> [static]</tt>
|
---|
586 | </h3>
|
---|
587 | Returns a list of all the widgets in the application.
|
---|
588 | <p> The list is created using <tt>new</tt> and must be deleted by the caller.
|
---|
589 | <p> The list is empty (<a href="qptrlist.html#isEmpty">QPtrList::isEmpty</a>()) if there are no widgets.
|
---|
590 | <p> Note that some of the widgets may be hidden.
|
---|
591 | <p> Example that updates all widgets:
|
---|
592 | <pre>
|
---|
593 | QWidgetList *list = QApplication::<a href="#allWidgets">allWidgets</a>();
|
---|
594 | QWidgetListIt it( *list ); // iterate over the widgets
|
---|
595 | <a href="qwidget.html">QWidget</a> * w;
|
---|
596 | while ( (w=it.current()) != 0 ) { // for each widget...
|
---|
597 | ++it;
|
---|
598 | w-><a href="qwidget.html#update">update</a>();
|
---|
599 | }
|
---|
600 | delete list; // delete the list, not the widgets
|
---|
601 | </pre>
|
---|
602 |
|
---|
603 | <p> The QWidgetList class is defined in the <tt>qwidgetlist.h</tt> header
|
---|
604 | file.
|
---|
605 | <p> <b>Warning:</b> Delete the list as soon as you have finished using it.
|
---|
606 | The widgets in the list may be deleted by someone else at any time.
|
---|
607 | <p> <p>See also <a href="#topLevelWidgets">topLevelWidgets</a>(), <a href="qwidget.html#visible-prop">QWidget::visible</a>, and <a href="qptrlist.html#isEmpty">QPtrList::isEmpty</a>().
|
---|
608 |
|
---|
609 | <h3 class=fn><a href="qstring.html">QString</a> <a name="applicationDirPath"></a>QApplication::applicationDirPath ()
|
---|
610 | </h3>
|
---|
611 | Returns the directory that contains the application executable.
|
---|
612 | <p> For example, if you have installed Qt in the <tt>C:\Trolltech\Qt</tt>
|
---|
613 | directory, and you run the <tt>demo</tt> example, this function will
|
---|
614 | return "C:/Trolltech/Qt/examples/demo".
|
---|
615 | <p> On Mac OS X this will point to the directory actually containing the
|
---|
616 | executable, which may be inside of an application bundle (if the
|
---|
617 | application is bundled).
|
---|
618 | <p> <b>Warning:</b> On Unix, this function assumes that argv[0] contains the file
|
---|
619 | name of the executable (which it normally does). It also assumes that
|
---|
620 | the current directory hasn't been changed by the application.
|
---|
621 | <p> <p>See also <a href="#applicationFilePath">applicationFilePath</a>().
|
---|
622 |
|
---|
623 | <h3 class=fn><a href="qstring.html">QString</a> <a name="applicationFilePath"></a>QApplication::applicationFilePath ()
|
---|
624 | </h3>
|
---|
625 | Returns the file path of the application executable.
|
---|
626 | <p> For example, if you have installed Qt in the <tt>C:\Trolltech\Qt</tt>
|
---|
627 | directory, and you run the <tt>demo</tt> example, this function will
|
---|
628 | return "C:/Trolltech/Qt/examples/demo/demo.exe".
|
---|
629 | <p> <b>Warning:</b> On Unix, this function assumes that argv[0] contains the file
|
---|
630 | name of the executable (which it normally does). It also assumes that
|
---|
631 | the current directory hasn't been changed by the application.
|
---|
632 | <p> <p>See also <a href="#applicationDirPath">applicationDirPath</a>().
|
---|
633 |
|
---|
634 | <h3 class=fn>int <a name="argc"></a>QApplication::argc () const
|
---|
635 | </h3>
|
---|
636 |
|
---|
637 | <p> Returns the number of command line arguments.
|
---|
638 | <p> The documentation for <a href="#argv">argv</a>() describes how to process command line
|
---|
639 | arguments.
|
---|
640 | <p> <p>See also <a href="#argv">argv</a>() and <a href="#QApplication">QApplication::QApplication</a>().
|
---|
641 |
|
---|
642 | <p>Examples: <a href="tutorial2-04.html#x2557">chart/main.cpp</a> and <a href="scribble-example.html#x906">scribble/scribble.cpp</a>.
|
---|
643 | <h3 class=fn>char ** <a name="argv"></a>QApplication::argv () const
|
---|
644 | </h3>
|
---|
645 |
|
---|
646 | <p> Returns the command line argument vector.
|
---|
647 | <p> <tt>argv()[0]</tt> is the program name, <tt>argv()[1]</tt> is the first
|
---|
648 | argument and <tt>argv()[argc()-1]</tt> is the last argument.
|
---|
649 | <p> A QApplication object is constructed by passing <em>argc</em> and <em>argv</em> from the <tt>main()</tt> function. Some of the arguments may be
|
---|
650 | recognized as Qt options and removed from the argument vector. For
|
---|
651 | example, the X11 version of Qt knows about <tt>-display</tt>, <tt>-font</tt>
|
---|
652 | and a few more options.
|
---|
653 | <p> Example:
|
---|
654 | <pre>
|
---|
655 | // showargs.cpp - displays program arguments in a list box
|
---|
656 |
|
---|
657 | #include <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
658 | #include <<a href="qlistbox-h.html">qlistbox.h</a>>
|
---|
659 |
|
---|
660 | int main( int argc, char **argv )
|
---|
661 | {
|
---|
662 | QApplication a( argc, argv );
|
---|
663 | <a href="qlistbox.html">QListBox</a> b;
|
---|
664 | a.<a href="#setMainWidget">setMainWidget</a>( &b );
|
---|
665 | for ( int i = 0; i < a.<a href="#argc">argc</a>(); i++ ) // a.<a href="#argc">argc</a>() == argc
|
---|
666 | b.<a href="qlistbox.html#insertItem">insertItem</a>( a.<a href="#argv">argv</a>()[i] ); // a.<a href="#argv">argv</a>()[i] == argv[i]
|
---|
667 | b.<a href="qwidget.html#show">show</a>();
|
---|
668 | return a.<a href="#exec">exec</a>();
|
---|
669 | }
|
---|
670 | </pre>
|
---|
671 |
|
---|
672 | <p> If you run <tt>showargs -display unix:0 -font 9x15bold hello world</tt>
|
---|
673 | under X11, the list box contains the three strings "showargs",
|
---|
674 | "hello" and "world".
|
---|
675 | <p> Qt provides a global pointer, <tt>qApp</tt>, that points to the
|
---|
676 | QApplication object, and through which you can access <a href="#argc">argc</a>() and
|
---|
677 | <a href="#argv">argv</a>() in functions other than main().
|
---|
678 | <p> <p>See also <a href="#argc">argc</a>() and <a href="#QApplication">QApplication::QApplication</a>().
|
---|
679 |
|
---|
680 | <p>Examples: <a href="tutorial2-04.html#x2558">chart/main.cpp</a> and <a href="scribble-example.html#x907">scribble/scribble.cpp</a>.
|
---|
681 | <h3 class=fn>void <a name="beep"></a>QApplication::beep ()<tt> [static]</tt>
|
---|
682 | </h3>
|
---|
683 | Sounds the bell, using the default volume and sound.
|
---|
684 |
|
---|
685 | <h3 class=fn><a href="qclipboard.html">QClipboard</a> * <a name="clipboard"></a>QApplication::clipboard ()<tt> [static]</tt>
|
---|
686 | </h3>
|
---|
687 | Returns a pointer to the application global clipboard.
|
---|
688 |
|
---|
689 | <p>Examples: <a href="regexptester-example.html#x2468">regexptester/regexptester.cpp</a> and <a href="showimg-example.html#x1308">showimg/showimg.cpp</a>.
|
---|
690 | <h3 class=fn>void <a name="closeAllWindows"></a>QApplication::closeAllWindows ()<tt> [slot]</tt>
|
---|
691 | </h3>
|
---|
692 | Closes all top-level windows.
|
---|
693 | <p> This function is particularly useful for applications with many
|
---|
694 | top-level windows. It could, for example, be connected to a "Quit"
|
---|
695 | entry in the file menu as shown in the following code example:
|
---|
696 | <p> <pre>
|
---|
697 | // the "Quit" menu entry should try to close all windows
|
---|
698 | <a href="qpopupmenu.html">QPopupMenu</a>* file = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
|
---|
699 | file-><a href="qmenudata.html#insertItem">insertItem</a>( "&Quit", qApp, SLOT(<a href="#closeAllWindows">closeAllWindows</a>()), CTRL+Key_Q );
|
---|
700 |
|
---|
701 | // when the last window is closed, the application should quit
|
---|
702 | <a href="qobject.html#connect">connect</a>( qApp, SIGNAL( <a href="#lastWindowClosed">lastWindowClosed</a>() ), qApp, SLOT( <a href="#quit">quit</a>() ) );
|
---|
703 | </pre>
|
---|
704 |
|
---|
705 | <p> The windows are closed in random order, until one window does not
|
---|
706 | accept the close event.
|
---|
707 | <p> <p>See also <a href="qwidget.html#close">QWidget::close</a>(), <a href="qwidget.html#closeEvent">QWidget::closeEvent</a>(), <a href="#lastWindowClosed">lastWindowClosed</a>(), <a href="#quit">quit</a>(), <a href="#topLevelWidgets">topLevelWidgets</a>(), and <a href="qwidget.html#isTopLevel-prop">QWidget::isTopLevel</a>.
|
---|
708 |
|
---|
709 | <p>
|
---|
710 | <p>Examples: <a href="qaction-application-example.html#x1127">action/application.cpp</a>, <a href="simple-application-example.html#x1544">application/application.cpp</a>, <a href="helpviewer-example.html#x980">helpviewer/helpwindow.cpp</a>, <a href="mdi-example.html#x2020">mdi/application.cpp</a>, and <a href="qwerty-example.html#x358">qwerty/qwerty.cpp</a>.
|
---|
711 | <h3 class=fn>bool <a name="closingDown"></a>QApplication::closingDown ()<tt> [static]</tt>
|
---|
712 | </h3>
|
---|
713 | Returns TRUE if the application objects are being destroyed;
|
---|
714 | otherwise returns FALSE.
|
---|
715 | <p> <p>See also <a href="#startingUp">startingUp</a>().
|
---|
716 |
|
---|
717 | <h3 class=fn>int <a name="colorSpec"></a>QApplication::colorSpec ()<tt> [static]</tt>
|
---|
718 | </h3>
|
---|
719 | Returns the color specification.
|
---|
720 | <p>See also <a href="#setColorSpec">QApplication::setColorSpec</a>().
|
---|
721 |
|
---|
722 | <p>Example: <a href="showimg-example.html#x1309">showimg/showimg.cpp</a>.
|
---|
723 | <h3 class=fn>void <a name="commitData"></a>QApplication::commitData ( <a href="qsessionmanager.html">QSessionManager</a> & sm )<tt> [virtual]</tt>
|
---|
724 | </h3>
|
---|
725 |
|
---|
726 | <p> This function deals with <a href="session.html">session
|
---|
727 | management</a>. It is invoked when the <a href="qsessionmanager.html">QSessionManager</a> wants the
|
---|
728 | application to commit all its data.
|
---|
729 | <p> Usually this means saving all open files, after getting
|
---|
730 | permission from the user. Furthermore you may want to provide a means
|
---|
731 | by which the user can cancel the shutdown.
|
---|
732 | <p> Note that you should not exit the application within this function.
|
---|
733 | Instead, the session manager may or may not do this afterwards,
|
---|
734 | depending on the context.
|
---|
735 | <p> <b>Warning:</b> Within this function, no user interaction is possible, <em>unless</em> you ask the session manager <em>sm</em> for explicit permission.
|
---|
736 | See <a href="qsessionmanager.html#allowsInteraction">QSessionManager::allowsInteraction</a>() and
|
---|
737 | <a href="qsessionmanager.html#allowsErrorInteraction">QSessionManager::allowsErrorInteraction</a>() for details and example
|
---|
738 | usage.
|
---|
739 | <p> The default implementation requests interaction and sends a close
|
---|
740 | event to all visible top level widgets. If any event was
|
---|
741 | rejected, the shutdown is canceled.
|
---|
742 | <p> <p>See also <a href="#isSessionRestored">isSessionRestored</a>(), <a href="#sessionId">sessionId</a>(), <a href="#saveState">saveState</a>(), and <a href="session.html">the Session Management overview</a>.
|
---|
743 |
|
---|
744 | <h3 class=fn>int <a name="cursorFlashTime"></a>QApplication::cursorFlashTime ()<tt> [static]</tt>
|
---|
745 | </h3>
|
---|
746 | Returns the text cursor's flash (blink) time in milliseconds. The
|
---|
747 | flash time is the time required to display, invert and restore the
|
---|
748 | caret display.
|
---|
749 | <p> The default value on X11 is 1000 milliseconds. On Windows, the
|
---|
750 | control panel value is used.
|
---|
751 | <p> Widgets should not cache this value since it may be changed at any
|
---|
752 | time by the user changing the global desktop settings.
|
---|
753 | <p> <p>See also <a href="#setCursorFlashTime">setCursorFlashTime</a>().
|
---|
754 |
|
---|
755 | <h3 class=fn><a href="qtextcodec.html">QTextCodec</a> * <a name="defaultCodec"></a>QApplication::defaultCodec () const
|
---|
756 | </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
757 | <p> Returns <a href="qtextcodec.html#codecForTr">QTextCodec::codecForTr</a>().
|
---|
758 |
|
---|
759 | <h3 class=fn><a href="qdesktopwidget.html">QDesktopWidget</a> * <a name="desktop"></a>QApplication::desktop ()<tt> [static]</tt>
|
---|
760 | </h3>
|
---|
761 | Returns the desktop widget (also called the root window).
|
---|
762 | <p> The desktop widget is useful for obtaining the size of the screen.
|
---|
763 | It may also be possible to draw on the desktop. We recommend against
|
---|
764 | assuming that it's possible to draw on the desktop, since this does
|
---|
765 | not work on all operating systems.
|
---|
766 | <p> <pre>
|
---|
767 | <a href="qdesktopwidget.html">QDesktopWidget</a> *d = QApplication::<a href="#desktop">desktop</a>();
|
---|
768 | int w = d-><a href="qwidget.html#width">width</a>(); // returns desktop width
|
---|
769 | int h = d-><a href="qwidget.html#height">height</a>(); // returns desktop height
|
---|
770 | </pre>
|
---|
771 |
|
---|
772 |
|
---|
773 | <p>Examples: <a href="canvas-example.html#x2958">canvas/main.cpp</a>, <a href="desktop-example.html#x1721">desktop/desktop.cpp</a>, <a href="helpviewer-example.html#x1037">helpviewer/main.cpp</a>, <a href="i18n-example.html#x1928">i18n/main.cpp</a>, <a href="qmag-example.html#x1765">qmag/qmag.cpp</a>, <a href="qwerty-example.html#x414">qwerty/main.cpp</a>, and <a href="scribble-example.html#x954">scribble/main.cpp</a>.
|
---|
774 | <h3 class=fn>bool <a name="desktopSettingsAware"></a>QApplication::desktopSettingsAware ()<tt> [static]</tt>
|
---|
775 | </h3>
|
---|
776 | Returns the value set by <a href="#setDesktopSettingsAware">setDesktopSettingsAware</a>(); by default TRUE.
|
---|
777 | <p> <p>See also <a href="#setDesktopSettingsAware">setDesktopSettingsAware</a>().
|
---|
778 |
|
---|
779 | <h3 class=fn>int <a name="doubleClickInterval"></a>QApplication::doubleClickInterval ()<tt> [static]</tt>
|
---|
780 | </h3>
|
---|
781 | Returns the maximum duration for a double click.
|
---|
782 | <p> The default value on X11 is 400 milliseconds. On Windows, the
|
---|
783 | control panel value is used.
|
---|
784 | <p> <p>See also <a href="#setDoubleClickInterval">setDoubleClickInterval</a>().
|
---|
785 |
|
---|
786 | <h3 class=fn>int <a name="enter_loop"></a>QApplication::enter_loop ()
|
---|
787 | </h3>
|
---|
788 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
789 | <p> This function enters the main event loop (recursively). Do not call
|
---|
790 | it unless you really know what you are doing.
|
---|
791 | <p> Use <a href="#eventLoop">QApplication::eventLoop</a>()->enterLoop() instead.
|
---|
792 | <p>
|
---|
793 | <h3 class=fn><a href="qeventloop.html">QEventLoop</a> * <a name="eventLoop"></a>QApplication::eventLoop ()<tt> [static]</tt>
|
---|
794 | </h3>
|
---|
795 | Returns the application event loop. This function will return
|
---|
796 | zero if called during and after destroying QApplication.
|
---|
797 | <p> To create your own instance of <a href="qeventloop.html">QEventLoop</a> or QEventLoop subclass create
|
---|
798 | it before you create the QApplication object.
|
---|
799 | <p> <p>See also <a href="qeventloop.html">QEventLoop</a>.
|
---|
800 |
|
---|
801 | <p>Example: <a href="distributor-example.html#x2651">distributor/distributor.ui.h</a>.
|
---|
802 | <h3 class=fn>int <a name="exec"></a>QApplication::exec ()
|
---|
803 | </h3>
|
---|
804 | Enters the main event loop and waits until <a href="#exit">exit</a>() is called or the
|
---|
805 | main widget is destroyed, and returns the value that was set to
|
---|
806 | exit() (which is 0 if exit() is called via <a href="#quit">quit</a>()).
|
---|
807 | <p> It is necessary to call this function to start event handling. The
|
---|
808 | main event loop receives events from the window system and
|
---|
809 | dispatches these to the application widgets.
|
---|
810 | <p> Generally speaking, no user interaction can take place before
|
---|
811 | calling <a href="#exec">exec</a>(). As a special case, modal widgets like <a href="qmessagebox.html">QMessageBox</a>
|
---|
812 | can be used before calling exec(), because modal widgets call
|
---|
813 | exec() to start a local event loop.
|
---|
814 | <p> To make your application perform idle processing, i.e. executing a
|
---|
815 | special function whenever there are no pending events, use a
|
---|
816 | <a href="qtimer.html">QTimer</a> with 0 timeout. More advanced idle processing schemes can
|
---|
817 | be achieved using <a href="#processEvents">processEvents</a>().
|
---|
818 | <p> <p>See also <a href="#quit">quit</a>(), <a href="#exit">exit</a>(), <a href="#processEvents">processEvents</a>(), and <a href="#setMainWidget">setMainWidget</a>().
|
---|
819 |
|
---|
820 | <p>Examples: <a href="helpsystem-example.html#x2700">helpsystem/main.cpp</a>, <a href="qdialog.html#x2132">life/main.cpp</a>, <a href="archivesearch-example.html#x486">network/archivesearch/main.cpp</a>, <a href="ftpclient-example.html#x777">network/ftpclient/main.cpp</a>, <a href="qaxserver-example-opengl.html#x2731">opengl/main.cpp</a>, <a href="tutorial1-01.html#x2283">t1/main.cpp</a>, and <a href="tutorial1-04.html#x2303">t4/main.cpp</a>.
|
---|
821 | <h3 class=fn>void <a name="exit"></a>QApplication::exit ( int retcode = 0 )<tt> [static]</tt>
|
---|
822 | </h3>
|
---|
823 | Tells the application to exit with a return code.
|
---|
824 | <p> After this function has been called, the application leaves the main
|
---|
825 | event loop and returns from the call to <a href="#exec">exec</a>(). The exec() function
|
---|
826 | returns <em>retcode</em>.
|
---|
827 | <p> By convention, a <em>retcode</em> of 0 means success, and any non-zero
|
---|
828 | value indicates an error.
|
---|
829 | <p> Note that unlike the C library function of the same name, this
|
---|
830 | function <em>does</em> return to the caller -- it is event processing that
|
---|
831 | stops.
|
---|
832 | <p> <p>See also <a href="#quit">quit</a>() and <a href="#exec">exec</a>().
|
---|
833 |
|
---|
834 | <p>Examples: <a href="canvas-chart-example.html#x2875">chart/chartform.cpp</a>, <a href="extension-dialog-example.html#x2865">extension/mainform.ui.h</a>, and <a href="picture-example.html#x106">picture/picture.cpp</a>.
|
---|
835 | <h3 class=fn>void <a name="exit_loop"></a>QApplication::exit_loop ()
|
---|
836 | </h3>
|
---|
837 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
838 | <p> This function exits from a recursive call to the main event loop.
|
---|
839 | Do not call it unless you are an expert.
|
---|
840 | <p> Use <a href="#eventLoop">QApplication::eventLoop</a>()->exitLoop() instead.
|
---|
841 | <p>
|
---|
842 | <h3 class=fn>void <a name="flush"></a>QApplication::flush ()<tt> [static]</tt>
|
---|
843 | </h3>
|
---|
844 | Flushes the window system specific event queues.
|
---|
845 | <p> If you are doing graphical changes inside a loop that does not
|
---|
846 | return to the event loop on asynchronous window systems like X11
|
---|
847 | or double buffered window systems like MacOS X, and you want to
|
---|
848 | visualize these changes immediately (e.g. Splash Screens), call
|
---|
849 | this function.
|
---|
850 | <p> <p>See also <a href="#flushX">flushX</a>(), <a href="#sendPostedEvents">sendPostedEvents</a>(), and <a href="qpainter.html#flush">QPainter::flush</a>().
|
---|
851 |
|
---|
852 | <h3 class=fn>void <a name="flushX"></a>QApplication::flushX ()<tt> [static]</tt>
|
---|
853 | </h3>
|
---|
854 | Flushes the X event queue in the X11 implementation. This normally
|
---|
855 | returns almost immediately. Does nothing on other platforms.
|
---|
856 | <p> <p>See also <a href="#syncX">syncX</a>().
|
---|
857 |
|
---|
858 | <p>Example: <a href="xform-example.html#x1217">xform/xform.cpp</a>.
|
---|
859 | <h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="focusWidget"></a>QApplication::focusWidget () const
|
---|
860 | </h3>
|
---|
861 |
|
---|
862 | <p> Returns the application widget that has the keyboard input focus, or
|
---|
863 | 0 if no widget in this application has the focus.
|
---|
864 | <p> <p>See also <a href="qwidget.html#setFocus">QWidget::setFocus</a>(), <a href="qwidget.html#focus-prop">QWidget::focus</a>, and <a href="#activeWindow">activeWindow</a>().
|
---|
865 |
|
---|
866 | <h3 class=fn><a href="qfont.html">QFont</a> <a name="font"></a>QApplication::font ( const <a href="qwidget.html">QWidget</a> * w = 0 )<tt> [static]</tt>
|
---|
867 | </h3>
|
---|
868 | Returns the default font for the widget <em>w</em>, or the default
|
---|
869 | application font if <em>w</em> is 0.
|
---|
870 | <p> <p>See also <a href="#setFont">setFont</a>(), <a href="#fontMetrics">fontMetrics</a>(), and <a href="qwidget.html#font-prop">QWidget::font</a>.
|
---|
871 |
|
---|
872 | <p>Examples: <a href="qfd-example.html#x1979">qfd/fontdisplayer.cpp</a>, <a href="themes-example.html#x264">themes/metal.cpp</a>, and <a href="themes-example.html#x321">themes/themes.cpp</a>.
|
---|
873 | <h3 class=fn><a href="qfontmetrics.html">QFontMetrics</a> <a name="fontMetrics"></a>QApplication::fontMetrics ()<tt> [static]</tt>
|
---|
874 | </h3>
|
---|
875 | Returns display (screen) font metrics for the application font.
|
---|
876 | <p> <p>See also <a href="#font">font</a>(), <a href="#setFont">setFont</a>(), <a href="qwidget.html#fontMetrics">QWidget::fontMetrics</a>(), and <a href="qpainter.html#fontMetrics">QPainter::fontMetrics</a>().
|
---|
877 |
|
---|
878 | <h3 class=fn><a href="qsize.html">QSize</a> <a name="globalStrut"></a>QApplication::globalStrut ()<tt> [static]</tt>
|
---|
879 | </h3>
|
---|
880 |
|
---|
881 | <p> Returns the application's global strut.
|
---|
882 | <p> The strut is a size object whose dimensions are the minimum that any
|
---|
883 | GUI element that the user can interact with should have. For example
|
---|
884 | no button should be resized to be smaller than the global strut size.
|
---|
885 | <p> <p>See also <a href="#setGlobalStrut">setGlobalStrut</a>().
|
---|
886 |
|
---|
887 | <h3 class=fn>void <a name="guiThreadAwake"></a>QApplication::guiThreadAwake ()<tt> [signal]</tt>
|
---|
888 | </h3>
|
---|
889 |
|
---|
890 | <p> This signal is emitted after the event loop returns from a function
|
---|
891 | that could block.
|
---|
892 | <p> <p>See also <a href="#wakeUpGuiThread">wakeUpGuiThread</a>().
|
---|
893 |
|
---|
894 | <h3 class=fn>bool <a name="hasGlobalMouseTracking"></a>QApplication::hasGlobalMouseTracking ()<tt> [static]</tt>
|
---|
895 | </h3>
|
---|
896 |
|
---|
897 | <p> Returns TRUE if global mouse tracking is enabled; otherwise
|
---|
898 | returns FALSE.
|
---|
899 | <p> <p>See also <a href="#setGlobalMouseTracking">setGlobalMouseTracking</a>().
|
---|
900 |
|
---|
901 | <h3 class=fn>bool <a name="hasPendingEvents"></a>QApplication::hasPendingEvents ()
|
---|
902 | </h3>
|
---|
903 | This function returns TRUE if there are pending events; otherwise
|
---|
904 | returns FALSE. Pending events can be either from the window system
|
---|
905 | or posted events using <a href="#postEvent">QApplication::postEvent</a>().
|
---|
906 |
|
---|
907 | <h3 class=fn>int <a name="horizontalAlignment"></a>QApplication::horizontalAlignment ( int align )<tt> [static]</tt>
|
---|
908 | </h3>
|
---|
909 |
|
---|
910 | <p> Strips out vertical alignment flags and transforms an
|
---|
911 | alignment <em>align</em> of AlignAuto into AlignLeft or
|
---|
912 | AlignRight according to the language used. The other horizontal
|
---|
913 | alignment flags are left untouched.
|
---|
914 |
|
---|
915 | <h3 class=fn>void <a name="installTranslator"></a>QApplication::installTranslator ( <a href="qtranslator.html">QTranslator</a> * mf )
|
---|
916 | </h3>
|
---|
917 | Adds the message file <em>mf</em> to the list of message files to be used
|
---|
918 | for translations.
|
---|
919 | <p> Multiple message files can be installed. Translations are searched
|
---|
920 | for in the last installed message file, then the one from last, and
|
---|
921 | so on, back to the first installed message file. The search stops as
|
---|
922 | soon as a matching translation is found.
|
---|
923 | <p> <p>See also <a href="#removeTranslator">removeTranslator</a>(), <a href="#translate">translate</a>(), and <a href="qtranslator.html#load">QTranslator::load</a>().
|
---|
924 |
|
---|
925 | <p>Example: <a href="i18n-example.html#x1930">i18n/main.cpp</a>.
|
---|
926 | <h3 class=fn>bool <a name="isEffectEnabled"></a>QApplication::isEffectEnabled ( <a href="qt.html#UIEffect-enum">Qt::UIEffect</a> effect )<tt> [static]</tt>
|
---|
927 | </h3>
|
---|
928 | Returns TRUE if <em>effect</em> is enabled; otherwise returns FALSE.
|
---|
929 | <p> By default, Qt will try to use the desktop settings. Call
|
---|
930 | <a href="#setDesktopSettingsAware">setDesktopSettingsAware</a>(FALSE) to prevent this.
|
---|
931 | <p> Note: All effects are disabled on screens running at less than
|
---|
932 | 16-bit color depth.
|
---|
933 | <p> <p>See also <a href="#setEffectEnabled">setEffectEnabled</a>() and <a href="qt.html#UIEffect-enum">Qt::UIEffect</a>.
|
---|
934 |
|
---|
935 | <h3 class=fn>bool <a name="isSessionRestored"></a>QApplication::isSessionRestored () const
|
---|
936 | </h3>
|
---|
937 |
|
---|
938 | <p> Returns TRUE if the application has been restored from an earlier
|
---|
939 | <a href="session.html">session</a>; otherwise returns FALSE.
|
---|
940 | <p> <p>See also <a href="#sessionId">sessionId</a>(), <a href="#commitData">commitData</a>(), and <a href="#saveState">saveState</a>().
|
---|
941 |
|
---|
942 | <h3 class=fn>void <a name="lastWindowClosed"></a>QApplication::lastWindowClosed ()<tt> [signal]</tt>
|
---|
943 | </h3>
|
---|
944 |
|
---|
945 | <p> This signal is emitted when the user has closed the last
|
---|
946 | top level window.
|
---|
947 | <p> The signal is very useful when your application has many top level
|
---|
948 | widgets but no main widget. You can then connect it to the <a href="#quit">quit</a>()
|
---|
949 | slot.
|
---|
950 | <p> For convenience, this signal is <em>not</em> emitted for transient top level
|
---|
951 | widgets such as popup menus and dialogs.
|
---|
952 | <p> <p>See also <a href="#mainWidget">mainWidget</a>(), <a href="#topLevelWidgets">topLevelWidgets</a>(), <a href="qwidget.html#isTopLevel-prop">QWidget::isTopLevel</a>, and <a href="qwidget.html#close">QWidget::close</a>().
|
---|
953 |
|
---|
954 | <p>Examples: <a href="addressbook-example.html#x608">addressbook/main.cpp</a>, <a href="extension-dialog-example.html#x2867">extension/main.cpp</a>, <a href="helpviewer-example.html#x1039">helpviewer/main.cpp</a>, <a href="mdi-example.html#x2096">mdi/main.cpp</a>, <a href="archivesearch-example.html#x487">network/archivesearch/main.cpp</a>, <a href="qwerty-example.html#x416">qwerty/main.cpp</a>, and <a href="regexptester-example.html#x2509">regexptester/main.cpp</a>.
|
---|
955 | <h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="libraryPaths"></a>QApplication::libraryPaths ()<tt> [static]</tt>
|
---|
956 | </h3>
|
---|
957 | Returns a list of paths that the application will search when
|
---|
958 | dynamically loading libraries.
|
---|
959 | The installation directory for plugins is the only entry if no
|
---|
960 | paths have been set. The default installation directory for plugins
|
---|
961 | is <tt>INSTALL/plugins</tt>, where <tt>INSTALL</tt> is the directory where Qt was
|
---|
962 | installed. The directory of the application executable (NOT the
|
---|
963 | working directory) is also added to the plugin paths.
|
---|
964 | <p> If you want to iterate over the list, you should iterate over a
|
---|
965 | copy, e.g.
|
---|
966 | <pre>
|
---|
967 | <a href="qstringlist.html">QStringList</a> list = app.libraryPaths();
|
---|
968 | QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
|
---|
969 | while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
|
---|
970 | myProcessing( *it );
|
---|
971 | ++it;
|
---|
972 | }
|
---|
973 | </pre>
|
---|
974 |
|
---|
975 | <p> See the <a href="plugins-howto.html">plugins documentation</a> for a
|
---|
976 | description of how the library paths are used.
|
---|
977 | <p> <p>See also <a href="#setLibraryPaths">setLibraryPaths</a>(), <a href="#addLibraryPath">addLibraryPath</a>(), <a href="#removeLibraryPath">removeLibraryPath</a>(), and <a href="qlibrary.html">QLibrary</a>.
|
---|
978 |
|
---|
979 | <h3 class=fn>void <a name="lock"></a>QApplication::lock ()
|
---|
980 | </h3>
|
---|
981 | <p> Lock the Qt Library Mutex. If another thread has already locked the
|
---|
982 | mutex, the calling thread will block until the other thread has
|
---|
983 | unlocked the mutex.
|
---|
984 | <p> <p>See also <a href="#unlock">unlock</a>(), <a href="#locked">locked</a>(), and <a href="threads.html">Thread Support in Qt</a>.
|
---|
985 |
|
---|
986 | <h3 class=fn>bool <a name="locked"></a>QApplication::locked ()
|
---|
987 | </h3>
|
---|
988 | <p> Returns TRUE if the Qt Library Mutex is locked by a different thread;
|
---|
989 | otherwise returns FALSE.
|
---|
990 | <p> <b>Warning:</b> Due to different implementations of recursive mutexes on
|
---|
991 | the supported platforms, calling this function from the same thread
|
---|
992 | that previously locked the mutex will give undefined results.
|
---|
993 | <p> <p>See also <a href="#lock">lock</a>(), <a href="#unlock">unlock</a>(), and <a href="threads.html">Thread Support in Qt</a>.
|
---|
994 |
|
---|
995 | <h3 class=fn>int <a name="loopLevel"></a>QApplication::loopLevel () const
|
---|
996 | </h3>
|
---|
997 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
998 | <p> Returns the current loop level.
|
---|
999 | <p> Use <a href="#eventLoop">QApplication::eventLoop</a>()->loopLevel() instead.
|
---|
1000 | <p>
|
---|
1001 | <h3 class=fn>bool <a name="macEventFilter"></a>QApplication::macEventFilter ( EventHandlerCallRef, EventRef )<tt> [virtual]</tt>
|
---|
1002 | </h3>
|
---|
1003 | This virtual function is only implemented under Macintosh.
|
---|
1004 | <p> If you create an application that inherits QApplication and
|
---|
1005 | reimplement this function, you get direct access to all Carbon Events
|
---|
1006 | that are received from the MacOS.
|
---|
1007 | <p> Return TRUE if you want to stop the event from being processed.
|
---|
1008 | Return FALSE for normal event dispatching.
|
---|
1009 |
|
---|
1010 | <h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="mainWidget"></a>QApplication::mainWidget () const
|
---|
1011 | </h3>
|
---|
1012 |
|
---|
1013 | <p> Returns the main application widget, or 0 if there is no main
|
---|
1014 | widget.
|
---|
1015 | <p> <p>See also <a href="#setMainWidget">setMainWidget</a>().
|
---|
1016 |
|
---|
1017 | <h3 class=fn>bool <a name="notify"></a>QApplication::notify ( <a href="qobject.html">QObject</a> * receiver, <a href="qevent.html">QEvent</a> * e )<tt> [virtual]</tt>
|
---|
1018 | </h3>
|
---|
1019 | Sends event <em>e</em> to <em>receiver</em>: <em>receiver</em>->event(<em>e</em>).
|
---|
1020 | Returns the value that is returned from the receiver's event handler.
|
---|
1021 | <p> For certain types of events (e.g. mouse and key events),
|
---|
1022 | the event will be propagated to the receiver's parent and so on up to
|
---|
1023 | the top-level object if the receiver is not interested in the event
|
---|
1024 | (i.e., it returns FALSE).
|
---|
1025 | <p> There are five different ways that events can be processed;
|
---|
1026 | reimplementing this virtual function is just one of them. All five
|
---|
1027 | approaches are listed below:
|
---|
1028 | <ol type=1>
|
---|
1029 | <li> Reimplementing this function. This is very powerful, providing
|
---|
1030 | complete control; but only one subclass can be qApp.
|
---|
1031 | <p> <li> Installing an event filter on qApp. Such an event filter is able
|
---|
1032 | to process all events for all widgets, so it's just as powerful as
|
---|
1033 | reimplementing <a href="#notify">notify</a>(); furthermore, it's possible to have more
|
---|
1034 | than one application-global event filter. Global event filters even
|
---|
1035 | see mouse events for <a href="qwidget.html#isEnabled">disabled
|
---|
1036 | widgets,</a> and if <a href="#setGlobalMouseTracking">global mouse
|
---|
1037 | tracking</a> is enabled, as well as mouse move events for all
|
---|
1038 | widgets.
|
---|
1039 | <p> <li> Reimplementing <a href="qobject.html#event">QObject::event</a>() (as <a href="qwidget.html">QWidget</a> does). If you do
|
---|
1040 | this you get Tab key presses, and you get to see the events before
|
---|
1041 | any widget-specific event filters.
|
---|
1042 | <p> <li> Installing an event filter on the object. Such an event filter
|
---|
1043 | gets all the events except Tab and Shift-Tab key presses.
|
---|
1044 | <p> <li> Reimplementing paintEvent(), mousePressEvent() and so
|
---|
1045 | on. This is the commonest, easiest and least powerful way.
|
---|
1046 | </ol>
|
---|
1047 | <p> <p>See also <a href="qobject.html#event">QObject::event</a>() and <a href="qobject.html#installEventFilter">installEventFilter</a>().
|
---|
1048 |
|
---|
1049 | <h3 class=fn><a href="qcursor.html">QCursor</a> * <a name="overrideCursor"></a>QApplication::overrideCursor ()<tt> [static]</tt>
|
---|
1050 | </h3>
|
---|
1051 |
|
---|
1052 | <p> Returns the active application override cursor.
|
---|
1053 | <p> This function returns 0 if no application cursor has been defined
|
---|
1054 | (i.e. the internal cursor stack is empty).
|
---|
1055 | <p> <p>See also <a href="#setOverrideCursor">setOverrideCursor</a>() and <a href="#restoreOverrideCursor">restoreOverrideCursor</a>().
|
---|
1056 |
|
---|
1057 | <h3 class=fn><a href="qpalette.html">QPalette</a> <a name="palette"></a>QApplication::palette ( const <a href="qwidget.html">QWidget</a> * w = 0 )<tt> [static]</tt>
|
---|
1058 | </h3>
|
---|
1059 | Returns the application palette.
|
---|
1060 | <p> If a widget is passed in <em>w</em>, the default palette for the
|
---|
1061 | widget's class is returned. This may or may not be the application
|
---|
1062 | palette. In most cases there isn't a special palette for certain
|
---|
1063 | types of widgets, but one notable exception is the popup menu under
|
---|
1064 | Windows, if the user has defined a special background color for
|
---|
1065 | menus in the display settings.
|
---|
1066 | <p> <p>See also <a href="#setPalette">setPalette</a>() and <a href="qwidget.html#palette-prop">QWidget::palette</a>.
|
---|
1067 |
|
---|
1068 | <p>Examples: <a href="desktop-example.html#x1723">desktop/desktop.cpp</a>, <a href="themes-example.html#x265">themes/metal.cpp</a>, and <a href="themes-example.html#x186">themes/wood.cpp</a>.
|
---|
1069 | <h3 class=fn>void <a name="polish"></a>QApplication::polish ( <a href="qwidget.html">QWidget</a> * w )<tt> [virtual]</tt>
|
---|
1070 | </h3>
|
---|
1071 | Initialization of the appearance of the widget <em>w</em> <em>before</em> it is first
|
---|
1072 | shown.
|
---|
1073 | <p> Usually widgets call this automatically when they are polished. It
|
---|
1074 | may be used to do some style-based central customization of widgets.
|
---|
1075 | <p> Note that you are not limited to the public functions of <a href="qwidget.html">QWidget</a>.
|
---|
1076 | Instead, based on meta information like <a href="qobject.html#className">QObject::className</a>() you are
|
---|
1077 | able to customize any kind of widget.
|
---|
1078 | <p> <p>See also <a href="qstyle.html#polish">QStyle::polish</a>(), <a href="qwidget.html#polish">QWidget::polish</a>(), <a href="#setPalette">setPalette</a>(), and <a href="#setFont">setFont</a>().
|
---|
1079 |
|
---|
1080 | <h3 class=fn>void <a name="postEvent"></a>QApplication::postEvent ( <a href="qobject.html">QObject</a> * receiver, <a href="qevent.html">QEvent</a> * event )<tt> [static]</tt>
|
---|
1081 | </h3><p><b>Note:</b> This function is <a href="threads.html#threadsafe">thread-safe</a> when Qt is built withthread support.</p>
|
---|
1082 |
|
---|
1083 | Adds the event <em>event</em> with the object <em>receiver</em> as the receiver of the
|
---|
1084 | event, to an event queue and returns immediately.
|
---|
1085 | <p> The event must be allocated on the heap since the post event queue
|
---|
1086 | will take ownership of the event and delete it once it has been posted.
|
---|
1087 | <p> When control returns to the main event loop, all events that are
|
---|
1088 | stored in the queue will be sent using the <a href="#notify">notify</a>() function.
|
---|
1089 | <p>
|
---|
1090 | <p> <p>See also <a href="#sendEvent">sendEvent</a>() and <a href="#notify">notify</a>().
|
---|
1091 |
|
---|
1092 | <h3 class=fn>void <a name="processEvents"></a>QApplication::processEvents ()
|
---|
1093 | </h3>
|
---|
1094 | Processes pending events, for 3 seconds or until there are no more
|
---|
1095 | events to process, whichever is shorter.
|
---|
1096 | <p> You can call this function occasionally when your program is busy
|
---|
1097 | performing a long operation (e.g. copying a file).
|
---|
1098 | <p> <p>See also <a href="#exec">exec</a>(), <a href="qtimer.html">QTimer</a>, and <a href="qeventloop.html#processEvents">QEventLoop::processEvents</a>().
|
---|
1099 |
|
---|
1100 | <p>Examples: <a href="fileiconview-example.html#x808">fileiconview/qfileiconview.cpp</a> and <a href="ftpclient-example.html#x778">network/ftpclient/main.cpp</a>.
|
---|
1101 | <h3 class=fn>void <a name="processEvents-2"></a>QApplication::processEvents ( int maxtime )
|
---|
1102 | </h3>
|
---|
1103 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
1104 | <p> Processes pending events for <em>maxtime</em> milliseconds or until
|
---|
1105 | there are no more events to process, whichever is shorter.
|
---|
1106 | <p> You can call this function occasionally when you program is busy
|
---|
1107 | doing a long operation (e.g. copying a file).
|
---|
1108 | <p> <p>See also <a href="#exec">exec</a>(), <a href="qtimer.html">QTimer</a>, and <a href="qeventloop.html#processEvents">QEventLoop::processEvents</a>().
|
---|
1109 |
|
---|
1110 | <h3 class=fn>void <a name="processOneEvent"></a>QApplication::processOneEvent ()
|
---|
1111 | </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
1112 | <p> Waits for an event to occur, processes it, then returns.
|
---|
1113 | <p> This function is useful for adapting Qt to situations where the
|
---|
1114 | event processing must be grafted onto existing program loops.
|
---|
1115 | <p> Using this function in new applications may be an indication of design
|
---|
1116 | problems.
|
---|
1117 | <p> <p>See also <a href="#processEvents">processEvents</a>(), <a href="#exec">exec</a>(), and <a href="qtimer.html">QTimer</a>.
|
---|
1118 |
|
---|
1119 | <h3 class=fn>void <a name="quit"></a>QApplication::quit ()<tt> [slot]</tt>
|
---|
1120 | </h3>
|
---|
1121 | Tells the application to exit with return code 0 (success).
|
---|
1122 | Equivalent to calling <a href="#exit">QApplication::exit</a>( 0 ).
|
---|
1123 | <p> It's common to connect the <a href="#lastWindowClosed">lastWindowClosed</a>() signal to <a href="#quit">quit</a>(), and
|
---|
1124 | you also often connect e.g. <a href="qbutton.html#clicked">QButton::clicked</a>() or signals in
|
---|
1125 | <a href="qaction.html">QAction</a>, <a href="qpopupmenu.html">QPopupMenu</a> or <a href="qmenubar.html">QMenuBar</a> to it.
|
---|
1126 | <p> Example:
|
---|
1127 | <pre>
|
---|
1128 | <a href="qpushbutton.html">QPushButton</a> *quitButton = new <a href="qpushbutton.html">QPushButton</a>( "Quit" );
|
---|
1129 | <a href="qobject.html#connect">connect</a>( quitButton, SIGNAL(<a href="qbutton.html#clicked">clicked</a>()), qApp, SLOT(<a href="#quit">quit</a>()) );
|
---|
1130 | </pre>
|
---|
1131 |
|
---|
1132 | <p> <p>See also <a href="#exit">exit</a>(), <a href="#aboutToQuit">aboutToQuit</a>(), <a href="#lastWindowClosed">lastWindowClosed</a>(), and <a href="qaction.html">QAction</a>.
|
---|
1133 |
|
---|
1134 | <p>Examples: <a href="addressbook-example.html#x609">addressbook/main.cpp</a>, <a href="mdi-example.html#x2097">mdi/main.cpp</a>, <a href="archivesearch-example.html#x488">network/archivesearch/main.cpp</a>, <a href="regexptester-example.html#x2510">regexptester/main.cpp</a>, <a href="tutorial1-02.html#x2288">t2/main.cpp</a>, <a href="tutorial1-04.html#x2304">t4/main.cpp</a>, and <a href="tutorial1-06.html#x2321">t6/main.cpp</a>.
|
---|
1135 | <h3 class=fn><a href="qwsdecoration.html">QWSDecoration</a> & <a name="qwsDecoration"></a>QApplication::qwsDecoration ()<tt> [static]</tt>
|
---|
1136 | </h3>
|
---|
1137 | Return the <a href="qwsdecoration.html">QWSDecoration</a> used for decorating windows.
|
---|
1138 | <p> This method is non-portable. It is available <em>only</em> in Qt/Embedded.
|
---|
1139 | <p> <p>See also <a href="qwsdecoration.html">QWSDecoration</a>.
|
---|
1140 |
|
---|
1141 | <h3 class=fn>bool <a name="qwsEventFilter"></a>QApplication::qwsEventFilter ( QWSEvent * )<tt> [virtual]</tt>
|
---|
1142 | </h3>
|
---|
1143 | This virtual function is only implemented under Qt/Embedded.
|
---|
1144 | <p> If you create an application that inherits QApplication and
|
---|
1145 | reimplement this function, you get direct access to all QWS (Q
|
---|
1146 | Window System) events that the are received from the QWS master
|
---|
1147 | process.
|
---|
1148 | <p> Return TRUE if you want to stop the event from being processed.
|
---|
1149 | Return FALSE for normal event dispatching.
|
---|
1150 |
|
---|
1151 | <h3 class=fn>void <a name="qwsSetCustomColors"></a>QApplication::qwsSetCustomColors ( QRgb * colorTable, int start, int numColors )
|
---|
1152 | </h3>
|
---|
1153 | Set Qt/Embedded custom color table.
|
---|
1154 | <p> Qt/Embedded on 8-bpp displays allocates a standard 216 color cube.
|
---|
1155 | The remaining 40 colors may be used by setting a custom color
|
---|
1156 | table in the QWS master process before any clients connect.
|
---|
1157 | <p> <em>colorTable</em> is an array of up to 40 custom colors. <em>start</em> is
|
---|
1158 | the starting index (0-39) and <em>numColors</em> is the number of colors
|
---|
1159 | to be set (1-40).
|
---|
1160 | <p> This method is non-portable. It is available <em>only</em> in
|
---|
1161 | Qt/Embedded.
|
---|
1162 |
|
---|
1163 | <h3 class=fn>void <a name="qwsSetDecoration"></a>QApplication::qwsSetDecoration ( <a href="qwsdecoration.html">QWSDecoration</a> * d )<tt> [static]</tt>
|
---|
1164 | </h3>
|
---|
1165 | Set the <a href="qwsdecoration.html">QWSDecoration</a> derived class to use for decorating the
|
---|
1166 | Qt/Embedded windows to <em>d</em>.
|
---|
1167 | <p> This method is non-portable. It is available <em>only</em> in
|
---|
1168 | Qt/Embedded.
|
---|
1169 | <p> <p>See also <a href="qwsdecoration.html">QWSDecoration</a>.
|
---|
1170 |
|
---|
1171 | <h3 class=fn>void <a name="removeLibraryPath"></a>QApplication::removeLibraryPath ( const <a href="qstring.html">QString</a> & path )<tt> [static]</tt>
|
---|
1172 | </h3>
|
---|
1173 | Removes <em>path</em> from the library path list. If <em>path</em> is empty or not
|
---|
1174 | in the path list, the list is not changed.
|
---|
1175 | <p> <p>See also <a href="#addLibraryPath">addLibraryPath</a>(), <a href="#libraryPaths">libraryPaths</a>(), and <a href="#setLibraryPaths">setLibraryPaths</a>().
|
---|
1176 |
|
---|
1177 | <h3 class=fn>void <a name="removePostedEvents"></a>QApplication::removePostedEvents ( <a href="qobject.html">QObject</a> * receiver )<tt> [static]</tt>
|
---|
1178 | </h3><p><b>Note:</b> This function is <a href="threads.html#threadsafe">thread-safe</a> when Qt is built withthread support.</p>
|
---|
1179 |
|
---|
1180 | Removes all events posted using <a href="#postEvent">postEvent</a>() for <em>receiver</em>.
|
---|
1181 | <p> The events are <em>not</em> dispatched, instead they are removed from the
|
---|
1182 | queue. You should never need to call this function. If you do call it,
|
---|
1183 | be aware that killing events may cause <em>receiver</em> to break one or
|
---|
1184 | more invariants.
|
---|
1185 | <p>
|
---|
1186 |
|
---|
1187 | <h3 class=fn>void <a name="removeTranslator"></a>QApplication::removeTranslator ( <a href="qtranslator.html">QTranslator</a> * mf )
|
---|
1188 | </h3>
|
---|
1189 | Removes the message file <em>mf</em> from the list of message files used by
|
---|
1190 | this application. (It does not delete the message file from the file
|
---|
1191 | system.)
|
---|
1192 | <p> <p>See also <a href="#installTranslator">installTranslator</a>(), <a href="#translate">translate</a>(), and <a href="qobject.html#tr">QObject::tr</a>().
|
---|
1193 |
|
---|
1194 | <p>Example: <a href="i18n-example.html#x1932">i18n/main.cpp</a>.
|
---|
1195 | <h3 class=fn>void <a name="restoreOverrideCursor"></a>QApplication::restoreOverrideCursor ()<tt> [static]</tt>
|
---|
1196 | </h3>
|
---|
1197 | Undoes the last <a href="#setOverrideCursor">setOverrideCursor</a>().
|
---|
1198 | <p> If setOverrideCursor() has been called twice, calling
|
---|
1199 | <a href="#restoreOverrideCursor">restoreOverrideCursor</a>() will activate the first cursor set.
|
---|
1200 | Calling this function a second time restores the original widgets'
|
---|
1201 | cursors.
|
---|
1202 | <p> <p>See also <a href="#setOverrideCursor">setOverrideCursor</a>() and <a href="#overrideCursor">overrideCursor</a>().
|
---|
1203 |
|
---|
1204 | <p>Examples: <a href="distributor-example.html#x2652">distributor/distributor.ui.h</a>, <a href="archivesearch-example.html#x473">network/archivesearch/archivedialog.ui.h</a>, <a href="ftpclient-example.html#x737">network/ftpclient/ftpmainwindow.ui.h</a>, and <a href="showimg-example.html#x1311">showimg/showimg.cpp</a>.
|
---|
1205 | <h3 class=fn>bool <a name="reverseLayout"></a>QApplication::reverseLayout ()<tt> [static]</tt>
|
---|
1206 | </h3>
|
---|
1207 | Returns TRUE if all dialogs and widgets will be laid out in a
|
---|
1208 | mirrored (right to left) fashion. Returns FALSE if dialogs and
|
---|
1209 | widgets will be laid out left to right.
|
---|
1210 | <p> <p>See also <a href="#setReverseLayout">setReverseLayout</a>().
|
---|
1211 |
|
---|
1212 | <h3 class=fn>void <a name="saveState"></a>QApplication::saveState ( <a href="qsessionmanager.html">QSessionManager</a> & sm )<tt> [virtual]</tt>
|
---|
1213 | </h3>
|
---|
1214 |
|
---|
1215 | <p> This function deals with <a href="session.html">session
|
---|
1216 | management</a>. It is invoked when the
|
---|
1217 | <a href="qsessionmanager.html">session manager</a> wants the application
|
---|
1218 | to preserve its state for a future session.
|
---|
1219 | <p> For example, a text editor would create a temporary file that
|
---|
1220 | includes the current contents of its edit buffers, the location of
|
---|
1221 | the cursor and other aspects of the current editing session.
|
---|
1222 | <p> Note that you should never exit the application within this
|
---|
1223 | function. Instead, the session manager may or may not do this
|
---|
1224 | afterwards, depending on the context. Futhermore, most session
|
---|
1225 | managers will very likely request a saved state immediately after
|
---|
1226 | the application has been started. This permits the session manager
|
---|
1227 | to learn about the application's restart policy.
|
---|
1228 | <p> <b>Warning:</b> Within this function, no user interaction is possible, <em>unless</em> you ask the session manager <em>sm</em> for explicit permission.
|
---|
1229 | See <a href="qsessionmanager.html#allowsInteraction">QSessionManager::allowsInteraction</a>() and
|
---|
1230 | <a href="qsessionmanager.html#allowsErrorInteraction">QSessionManager::allowsErrorInteraction</a>() for details.
|
---|
1231 | <p> <p>See also <a href="#isSessionRestored">isSessionRestored</a>(), <a href="#sessionId">sessionId</a>(), <a href="#commitData">commitData</a>(), and <a href="session.html">the Session Management overview</a>.
|
---|
1232 |
|
---|
1233 | <h3 class=fn>bool <a name="sendEvent"></a>QApplication::sendEvent ( <a href="qobject.html">QObject</a> * receiver, <a href="qevent.html">QEvent</a> * event )<tt> [static]</tt>
|
---|
1234 | </h3>
|
---|
1235 |
|
---|
1236 | <p> Sends event <em>event</em> directly to receiver <em>receiver</em>, using the
|
---|
1237 | <a href="#notify">notify</a>() function. Returns the value that was returned from the event
|
---|
1238 | handler.
|
---|
1239 | <p> The event is <em>not</em> deleted when the event has been sent. The normal
|
---|
1240 | approach is to create the event on the stack, e.g.
|
---|
1241 | <pre>
|
---|
1242 | <a href="qmouseevent.html">QMouseEvent</a> me( QEvent::MouseButtonPress, pos, 0, 0 );
|
---|
1243 | QApplication::<a href="#sendEvent">sendEvent</a>( mainWindow, &me );
|
---|
1244 | </pre>
|
---|
1245 |
|
---|
1246 | If you create the event on the heap you must delete it.
|
---|
1247 | <p> <p>See also <a href="#postEvent">postEvent</a>() and <a href="#notify">notify</a>().
|
---|
1248 |
|
---|
1249 | <p>Example: <a href="popup-example.html#x1602">popup/popup.cpp</a>.
|
---|
1250 | <h3 class=fn>void <a name="sendPostedEvents"></a>QApplication::sendPostedEvents ( <a href="qobject.html">QObject</a> * receiver, int event_type )<tt> [static]</tt>
|
---|
1251 | </h3>
|
---|
1252 | Immediately dispatches all events which have been previously queued
|
---|
1253 | with <a href="#postEvent">QApplication::postEvent</a>() and which are for the object <em>receiver</em>
|
---|
1254 | and have the event type <em>event_type</em>.
|
---|
1255 | <p> Note that events from the window system are <em>not</em> dispatched by this
|
---|
1256 | function, but by <a href="#processEvents">processEvents</a>().
|
---|
1257 | <p> If <em>receiver</em> is null, the events of <em>event_type</em> are sent for all
|
---|
1258 | objects. If <em>event_type</em> is 0, all the events are sent for <em>receiver</em>.
|
---|
1259 |
|
---|
1260 | <h3 class=fn>void <a name="sendPostedEvents-2"></a>QApplication::sendPostedEvents ()<tt> [static]</tt>
|
---|
1261 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
1262 | <p> Dispatches all posted events, i.e. empties the event queue.
|
---|
1263 |
|
---|
1264 | <h3 class=fn><a href="qstring.html">QString</a> <a name="sessionId"></a>QApplication::sessionId () const
|
---|
1265 | </h3>
|
---|
1266 |
|
---|
1267 | <p> Returns the current <a href="session.html">session's</a> identifier.
|
---|
1268 | <p> If the application has been restored from an earlier session, this
|
---|
1269 | identifier is the same as it was in that previous session.
|
---|
1270 | <p> The session identifier is guaranteed to be unique both for different
|
---|
1271 | applications and for different instances of the same application.
|
---|
1272 | <p> <p>See also <a href="#isSessionRestored">isSessionRestored</a>(), <a href="#sessionKey">sessionKey</a>(), <a href="#commitData">commitData</a>(), and <a href="#saveState">saveState</a>().
|
---|
1273 |
|
---|
1274 | <h3 class=fn><a href="qstring.html">QString</a> <a name="sessionKey"></a>QApplication::sessionKey () const
|
---|
1275 | </h3>
|
---|
1276 |
|
---|
1277 | <p> Returns the session key in the current <a href="session.html">session</a>.
|
---|
1278 | <p> If the application has been restored from an earlier session, this
|
---|
1279 | key is the same as it was when the previous session ended.
|
---|
1280 | <p> The session key changes with every call of <a href="#commitData">commitData</a>() or
|
---|
1281 | <a href="#saveState">saveState</a>().
|
---|
1282 | <p> <p>See also <a href="#isSessionRestored">isSessionRestored</a>(), <a href="#sessionId">sessionId</a>(), <a href="#commitData">commitData</a>(), and <a href="#saveState">saveState</a>().
|
---|
1283 |
|
---|
1284 | <h3 class=fn>void <a name="setColorSpec"></a>QApplication::setColorSpec ( int spec )<tt> [static]</tt>
|
---|
1285 | </h3>
|
---|
1286 | Sets the color specification for the application to <em>spec</em>.
|
---|
1287 | <p> The color specification controls how the application allocates colors
|
---|
1288 | when run on a display with a limited amount of colors, e.g. 8 bit / 256
|
---|
1289 | color displays.
|
---|
1290 | <p> The color specification must be set before you create the QApplication
|
---|
1291 | object.
|
---|
1292 | <p> The options are:
|
---|
1293 | <ul>
|
---|
1294 | <li> QApplication::NormalColor.
|
---|
1295 | This is the default color allocation strategy. Use this option if
|
---|
1296 | your application uses buttons, menus, texts and pixmaps with few
|
---|
1297 | colors. With this option, the application uses system global
|
---|
1298 | colors. This works fine for most applications under X11, but on
|
---|
1299 | Windows machines it may cause dithering of non-standard colors.
|
---|
1300 | <li> QApplication::CustomColor.
|
---|
1301 | Use this option if your application needs a small number of custom
|
---|
1302 | colors. On X11, this option is the same as NormalColor. On Windows, Qt
|
---|
1303 | creates a Windows palette, and allocates colors to it on demand.
|
---|
1304 | <li> QApplication::ManyColor.
|
---|
1305 | Use this option if your application is very color hungry
|
---|
1306 | (e.g. it requires thousands of colors).
|
---|
1307 | Under X11 the effect is:
|
---|
1308 | <ul>
|
---|
1309 | <li> For 256-color displays which have at best a 256 color true color
|
---|
1310 | visual, the default visual is used, and colors are allocated
|
---|
1311 | from a color cube. The color cube is the 6x6x6 (216 color) "Web
|
---|
1312 | palette"<sup>*</sup>, but the number of colors can be changed
|
---|
1313 | by the <em>-ncols</em> option. The user can force the application to
|
---|
1314 | use the true color visual with the <a href="#QApplication">-visual</a> option.
|
---|
1315 | <li> For 256-color displays which have a true color visual with more
|
---|
1316 | than 256 colors, use that visual. Silicon Graphics X servers
|
---|
1317 | have this feature, for example. They provide an 8 bit visual
|
---|
1318 | by default but can deliver true color when asked.
|
---|
1319 | </ul>
|
---|
1320 | On Windows, Qt creates a Windows palette, and fills it with a color cube.
|
---|
1321 | </ul>
|
---|
1322 | <p> Be aware that the CustomColor and ManyColor choices may lead to colormap
|
---|
1323 | flashing: The foreground application gets (most) of the available
|
---|
1324 | colors, while the background windows will look less attractive.
|
---|
1325 | <p> Example:
|
---|
1326 | <pre>
|
---|
1327 | int main( int argc, char **argv )
|
---|
1328 | {
|
---|
1329 | QApplication::<a href="#setColorSpec">setColorSpec</a>( QApplication::<a href="#ColorSpec-enum">ManyColor</a> );
|
---|
1330 | QApplication a( argc, argv );
|
---|
1331 | ...
|
---|
1332 | }
|
---|
1333 | </pre>
|
---|
1334 |
|
---|
1335 | <p> <a href="qcolor.html">QColor</a> provides more functionality for controlling color allocation and
|
---|
1336 | freeing up certain colors. See <a href="qcolor.html#enterAllocContext">QColor::enterAllocContext</a>() for more
|
---|
1337 | information.
|
---|
1338 | <p> To check what mode you end up with, call <a href="qcolor.html#numBitPlanes">QColor::numBitPlanes</a>() once
|
---|
1339 | the QApplication object exists. A value greater than 8 (typically
|
---|
1340 | 16, 24 or 32) means true color.
|
---|
1341 | <p> <sup>*</sup> The color cube used by Qt has 216 colors whose red,
|
---|
1342 | green, and blue components always have one of the following values:
|
---|
1343 | 0x00, 0x33, 0x66, 0x99, 0xCC, or 0xFF.
|
---|
1344 | <p> <p>See also <a href="#colorSpec">colorSpec</a>(), <a href="qcolor.html#numBitPlanes">QColor::numBitPlanes</a>(), and <a href="qcolor.html#enterAllocContext">QColor::enterAllocContext</a>().
|
---|
1345 |
|
---|
1346 | <p>Examples: <a href="helpviewer-example.html#x1041">helpviewer/main.cpp</a>, <a href="qaxserver-example-opengl.html#x2732">opengl/main.cpp</a>, <a href="showimg-example.html#x1361">showimg/main.cpp</a>, <a href="tutorial1-09.html#x2347">t9/main.cpp</a>, <a href="qaxserver-example-tetrax.html#x2716">tetrax/tetrax.cpp</a>, <a href="tetrix-example.html#x354">tetrix/tetrix.cpp</a>, and <a href="themes-example.html#x348">themes/main.cpp</a>.
|
---|
1347 | <h3 class=fn>void <a name="setCursorFlashTime"></a>QApplication::setCursorFlashTime ( int msecs )<tt> [static]</tt>
|
---|
1348 | </h3>
|
---|
1349 | Sets the text cursor's flash (blink) time to <em>msecs</em>
|
---|
1350 | milliseconds. The flash time is the time required to display,
|
---|
1351 | invert and restore the caret display. Usually the text cursor is
|
---|
1352 | displayed for <em>msecs/2</em> milliseconds, then hidden for <em>msecs/2</em>
|
---|
1353 | milliseconds, but this may vary.
|
---|
1354 | <p> Note that on Microsoft Windows, calling this function sets the
|
---|
1355 | cursor flash time for all windows.
|
---|
1356 | <p> <p>See also <a href="#cursorFlashTime">cursorFlashTime</a>().
|
---|
1357 |
|
---|
1358 | <h3 class=fn>void <a name="setDefaultCodec"></a>QApplication::setDefaultCodec ( <a href="qtextcodec.html">QTextCodec</a> * codec )
|
---|
1359 | </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
1360 | <p> This is the same as <a href="qtextcodec.html#setCodecForTr">QTextCodec::setCodecForTr</a>().
|
---|
1361 |
|
---|
1362 | <h3 class=fn>void <a name="setDesktopSettingsAware"></a>QApplication::setDesktopSettingsAware ( bool on )<tt> [static]</tt>
|
---|
1363 | </h3>
|
---|
1364 | By default, Qt will try to use the current standard colors, fonts
|
---|
1365 | etc., from the underlying window system's desktop settings,
|
---|
1366 | and use them for all relevant widgets. This behavior can be switched off
|
---|
1367 | by calling this function with <em>on</em> set to FALSE.
|
---|
1368 | <p> This static function must be called before creating the QApplication
|
---|
1369 | object, like this:
|
---|
1370 | <p> <pre>
|
---|
1371 | int main( int argc, char** argv ) {
|
---|
1372 | QApplication::<a href="#setDesktopSettingsAware">setDesktopSettingsAware</a>( FALSE ); // I know better than the user
|
---|
1373 | QApplication myApp( argc, argv ); // Use default fonts & colors
|
---|
1374 | ...
|
---|
1375 | }
|
---|
1376 | </pre>
|
---|
1377 |
|
---|
1378 | <p> <p>See also <a href="#desktopSettingsAware">desktopSettingsAware</a>().
|
---|
1379 |
|
---|
1380 | <h3 class=fn>void <a name="setDoubleClickInterval"></a>QApplication::setDoubleClickInterval ( int ms )<tt> [static]</tt>
|
---|
1381 | </h3>
|
---|
1382 | Sets the time limit that distinguishes a double click from two
|
---|
1383 | consecutive mouse clicks to <em>ms</em> milliseconds.
|
---|
1384 | <p> Note that on Microsoft Windows, calling this function sets the
|
---|
1385 | double click interval for all windows.
|
---|
1386 | <p> <p>See also <a href="#doubleClickInterval">doubleClickInterval</a>().
|
---|
1387 |
|
---|
1388 | <h3 class=fn>void <a name="setEffectEnabled"></a>QApplication::setEffectEnabled ( <a href="qt.html#UIEffect-enum">Qt::UIEffect</a> effect, bool enable = TRUE )<tt> [static]</tt>
|
---|
1389 | </h3>
|
---|
1390 | Enables the UI effect <em>effect</em> if <em>enable</em> is TRUE, otherwise
|
---|
1391 | the effect will not be used.
|
---|
1392 | <p> Note: All effects are disabled on screens running at less than
|
---|
1393 | 16-bit color depth.
|
---|
1394 | <p> <p>See also <a href="#isEffectEnabled">isEffectEnabled</a>(), <a href="qt.html#UIEffect-enum">Qt::UIEffect</a>, and <a href="#setDesktopSettingsAware">setDesktopSettingsAware</a>().
|
---|
1395 |
|
---|
1396 | <h3 class=fn>void <a name="setFont"></a>QApplication::setFont ( const <a href="qfont.html">QFont</a> & font, bool informWidgets = FALSE, const char * className = 0 )<tt> [static]</tt>
|
---|
1397 | </h3> Changes the default application font to <em>font</em>. If <em>informWidgets</em> is TRUE, then existing widgets are informed about the
|
---|
1398 | change and may adjust themselves to the new application
|
---|
1399 | setting. If <em>informWidgets</em> is FALSE, the change only affects newly
|
---|
1400 | created widgets. If <em>className</em> is passed, the change applies only
|
---|
1401 | to classes that inherit <em>className</em> (as reported by
|
---|
1402 | <a href="qobject.html#inherits">QObject::inherits</a>()).
|
---|
1403 | <p> On application start-up, the default font depends on the window
|
---|
1404 | system. It can vary depending on both the window system version and
|
---|
1405 | the locale. This function lets you override the default font; but
|
---|
1406 | overriding may be a bad idea because, for example, some locales need
|
---|
1407 | extra-large fonts to support their special characters.
|
---|
1408 | <p> <p>See also <a href="#font">font</a>(), <a href="#fontMetrics">fontMetrics</a>(), and <a href="qwidget.html#font-prop">QWidget::font</a>.
|
---|
1409 |
|
---|
1410 | <p>Examples: <a href="desktop-example.html#x1724">desktop/desktop.cpp</a>, <a href="themes-example.html#x266">themes/metal.cpp</a>, and <a href="themes-example.html#x323">themes/themes.cpp</a>.
|
---|
1411 | <h3 class=fn>void <a name="setGlobalMouseTracking"></a>QApplication::setGlobalMouseTracking ( bool enable )<tt> [static]</tt>
|
---|
1412 | </h3>
|
---|
1413 | Enables global mouse tracking if <em>enable</em> is TRUE, or disables it
|
---|
1414 | if <em>enable</em> is FALSE.
|
---|
1415 | <p> Enabling global mouse tracking makes it possible for widget event
|
---|
1416 | filters or application event filters to get all mouse move events,
|
---|
1417 | even when no button is depressed. This is useful for special GUI
|
---|
1418 | elements, e.g. tooltips.
|
---|
1419 | <p> Global mouse tracking does not affect widgets and their
|
---|
1420 | mouseMoveEvent(). For a widget to get mouse move events when no
|
---|
1421 | button is depressed, it must do <a href="qwidget.html#setMouseTracking">QWidget::setMouseTracking</a>(TRUE).
|
---|
1422 | <p> This function uses an internal counter. Each
|
---|
1423 | <a href="#setGlobalMouseTracking">setGlobalMouseTracking</a>(TRUE) must have a corresponding
|
---|
1424 | setGlobalMouseTracking(FALSE):
|
---|
1425 | <pre>
|
---|
1426 | // at this point global mouse tracking is off
|
---|
1427 | QApplication::<a href="#setGlobalMouseTracking">setGlobalMouseTracking</a>( TRUE );
|
---|
1428 | QApplication::<a href="#setGlobalMouseTracking">setGlobalMouseTracking</a>( TRUE );
|
---|
1429 | QApplication::<a href="#setGlobalMouseTracking">setGlobalMouseTracking</a>( FALSE );
|
---|
1430 | // at this point it's still on
|
---|
1431 | QApplication::<a href="#setGlobalMouseTracking">setGlobalMouseTracking</a>( FALSE );
|
---|
1432 | // but now it's off
|
---|
1433 | </pre>
|
---|
1434 |
|
---|
1435 | <p> <p>See also <a href="#hasGlobalMouseTracking">hasGlobalMouseTracking</a>() and <a href="qwidget.html#mouseTracking-prop">QWidget::mouseTracking</a>.
|
---|
1436 |
|
---|
1437 | <h3 class=fn>void <a name="setGlobalStrut"></a>QApplication::setGlobalStrut ( const <a href="qsize.html">QSize</a> & strut )<tt> [static]</tt>
|
---|
1438 | </h3>
|
---|
1439 | Sets the application's global strut to <em>strut</em>.
|
---|
1440 | <p> The strut is a size object whose dimensions are the minimum that any
|
---|
1441 | GUI element that the user can interact with should have. For example
|
---|
1442 | no button should be resized to be smaller than the global strut size.
|
---|
1443 | <p> The strut size should be considered when reimplementing GUI controls
|
---|
1444 | that may be used on touch-screens or similar IO-devices.
|
---|
1445 | <p> Example:
|
---|
1446 | <pre>
|
---|
1447 | QSize& WidgetClass::sizeHint() const
|
---|
1448 | {
|
---|
1449 | return QSize( 80, 25 ).expandedTo( QApplication::<a href="#globalStrut">globalStrut</a>() );
|
---|
1450 | }
|
---|
1451 | </pre>
|
---|
1452 |
|
---|
1453 | <p> <p>See also <a href="#globalStrut">globalStrut</a>().
|
---|
1454 |
|
---|
1455 | <h3 class=fn>void <a name="setLibraryPaths"></a>QApplication::setLibraryPaths ( const <a href="qstringlist.html">QStringList</a> & paths )<tt> [static]</tt>
|
---|
1456 | </h3>
|
---|
1457 | Sets the list of directories to search when loading libraries to <em>paths</em>.
|
---|
1458 | All existing paths will be deleted and the path list will consist of the
|
---|
1459 | paths given in <em>paths</em>.
|
---|
1460 | <p> <p>See also <a href="#libraryPaths">libraryPaths</a>(), <a href="#addLibraryPath">addLibraryPath</a>(), <a href="#removeLibraryPath">removeLibraryPath</a>(), and <a href="qlibrary.html">QLibrary</a>.
|
---|
1461 |
|
---|
1462 | <h3 class=fn>void <a name="setMainWidget"></a>QApplication::setMainWidget ( <a href="qwidget.html">QWidget</a> * mainWidget )<tt> [virtual]</tt>
|
---|
1463 | </h3>
|
---|
1464 | Sets the application's main widget to <em>mainWidget</em>.
|
---|
1465 | <p> In most respects the main widget is like any other widget, except
|
---|
1466 | that if it is closed, the application exits. Note that
|
---|
1467 | QApplication does <em>not</em> take ownership of the <em>mainWidget</em>, so
|
---|
1468 | if you create your main widget on the heap you must delete it
|
---|
1469 | yourself.
|
---|
1470 | <p> You need not have a main widget; connecting <a href="#lastWindowClosed">lastWindowClosed</a>() to
|
---|
1471 | <a href="#quit">quit</a>() is an alternative.
|
---|
1472 | <p> For X11, this function also resizes and moves the main widget
|
---|
1473 | according to the <em>-geometry</em> command-line option, so you should
|
---|
1474 | set the default geometry (using <a href="qwidget.html#setGeometry">QWidget::setGeometry</a>()) before
|
---|
1475 | calling <a href="#setMainWidget">setMainWidget</a>().
|
---|
1476 | <p> <p>See also <a href="#mainWidget">mainWidget</a>(), <a href="#exec">exec</a>(), and <a href="#quit">quit</a>().
|
---|
1477 |
|
---|
1478 | <p>Examples: <a href="tutorial2-04.html#x2560">chart/main.cpp</a>, <a href="helpsystem-example.html#x2701">helpsystem/main.cpp</a>, <a href="qdialog.html#x2133">life/main.cpp</a>, <a href="ftpclient-example.html#x779">network/ftpclient/main.cpp</a>, <a href="qaxserver-example-opengl.html#x2733">opengl/main.cpp</a>, <a href="tutorial1-01.html#x2284">t1/main.cpp</a>, and <a href="tutorial1-04.html#x2305">t4/main.cpp</a>.
|
---|
1479 | <h3 class=fn>void <a name="setOverrideCursor"></a>QApplication::setOverrideCursor ( const <a href="qcursor.html">QCursor</a> & cursor, bool replace = FALSE )<tt> [static]</tt>
|
---|
1480 | </h3>
|
---|
1481 | Sets the application override cursor to <em>cursor</em>.
|
---|
1482 | <p> Application override cursors are intended for showing the user
|
---|
1483 | that the application is in a special state, for example during an
|
---|
1484 | operation that might take some time.
|
---|
1485 | <p> This cursor will be displayed in all the application's widgets
|
---|
1486 | until <a href="#restoreOverrideCursor">restoreOverrideCursor</a>() or another <a href="#setOverrideCursor">setOverrideCursor</a>() is
|
---|
1487 | called.
|
---|
1488 | <p> Application cursors are stored on an internal stack.
|
---|
1489 | setOverrideCursor() pushes the cursor onto the stack, and
|
---|
1490 | restoreOverrideCursor() pops the active cursor off the stack.
|
---|
1491 | Every setOverrideCursor() must eventually be followed by a
|
---|
1492 | corresponding restoreOverrideCursor(), otherwise the stack will
|
---|
1493 | never be emptied.
|
---|
1494 | <p> If <em>replace</em> is TRUE, the new cursor will replace the last
|
---|
1495 | override cursor (the stack keeps its depth). If <em>replace</em> is
|
---|
1496 | FALSE, the new stack is pushed onto the top of the stack.
|
---|
1497 | <p> Example:
|
---|
1498 | <pre>
|
---|
1499 | QApplication::<a href="#setOverrideCursor">setOverrideCursor</a>( QCursor(Qt::<a href="qt.html#CursorShape-enum">WaitCursor</a>) );
|
---|
1500 | calculateHugeMandelbrot(); // lunch time...
|
---|
1501 | QApplication::<a href="#restoreOverrideCursor">restoreOverrideCursor</a>();
|
---|
1502 | </pre>
|
---|
1503 |
|
---|
1504 | <p> <p>See also <a href="#overrideCursor">overrideCursor</a>(), <a href="#restoreOverrideCursor">restoreOverrideCursor</a>(), and <a href="qwidget.html#cursor-prop">QWidget::cursor</a>.
|
---|
1505 |
|
---|
1506 | <p>Examples: <a href="distributor-example.html#x2653">distributor/distributor.ui.h</a>, <a href="archivesearch-example.html#x474">network/archivesearch/archivedialog.ui.h</a>, <a href="ftpclient-example.html#x738">network/ftpclient/ftpmainwindow.ui.h</a>, and <a href="showimg-example.html#x1312">showimg/showimg.cpp</a>.
|
---|
1507 | <h3 class=fn>void <a name="setPalette"></a>QApplication::setPalette ( const <a href="qpalette.html">QPalette</a> & palette, bool informWidgets = FALSE, const char * className = 0 )<tt> [static]</tt>
|
---|
1508 | </h3>
|
---|
1509 | Changes the default application palette to <em>palette</em>. If <em>informWidgets</em> is TRUE, then existing widgets are informed about the
|
---|
1510 | change and may adjust themselves to the new application
|
---|
1511 | setting. If <em>informWidgets</em> is FALSE, the change only affects newly
|
---|
1512 | created widgets.
|
---|
1513 | <p> If <em>className</em> is passed, the change applies only to widgets that
|
---|
1514 | inherit <em>className</em> (as reported by <a href="qobject.html#inherits">QObject::inherits</a>()). If
|
---|
1515 | <em>className</em> is left 0, the change affects all widgets, thus overriding
|
---|
1516 | any previously set class specific palettes.
|
---|
1517 | <p> The palette may be changed according to the current GUI style in
|
---|
1518 | <a href="qstyle.html#polish">QStyle::polish</a>().
|
---|
1519 | <p> <p>See also <a href="qwidget.html#palette-prop">QWidget::palette</a>, <a href="#palette">palette</a>(), and <a href="qstyle.html#polish">QStyle::polish</a>().
|
---|
1520 |
|
---|
1521 | <p>Examples: <a href="i18n-example.html#x1934">i18n/main.cpp</a>, <a href="themes-example.html#x267">themes/metal.cpp</a>, <a href="themes-example.html#x324">themes/themes.cpp</a>, and <a href="themes-example.html#x187">themes/wood.cpp</a>.
|
---|
1522 | <h3 class=fn>void <a name="setReverseLayout"></a>QApplication::setReverseLayout ( bool b )<tt> [static]</tt>
|
---|
1523 | </h3>
|
---|
1524 | If <em>b</em> is TRUE, all dialogs and widgets will be laid out in a
|
---|
1525 | mirrored fashion, as required by right to left languages such as
|
---|
1526 | Arabic and Hebrew. If <em>b</em> is FALSE, dialogs and widgets are laid
|
---|
1527 | out left to right.
|
---|
1528 | <p> Changing this flag in runtime does not cause a relayout of already
|
---|
1529 | instantiated widgets.
|
---|
1530 | <p> <p>See also <a href="#reverseLayout">reverseLayout</a>().
|
---|
1531 |
|
---|
1532 | <h3 class=fn>void <a name="setStartDragDistance"></a>QApplication::setStartDragDistance ( int l )<tt> [static]</tt>
|
---|
1533 | </h3>
|
---|
1534 | Sets the distance after which a drag should start to <em>l</em> pixels.
|
---|
1535 | <p> <p>See also <a href="#startDragDistance">startDragDistance</a>().
|
---|
1536 |
|
---|
1537 | <h3 class=fn>void <a name="setStartDragTime"></a>QApplication::setStartDragTime ( int ms )<tt> [static]</tt>
|
---|
1538 | </h3>
|
---|
1539 | Sets the time after which a drag should start to <em>ms</em> ms.
|
---|
1540 | <p> <p>See also <a href="#startDragTime">startDragTime</a>().
|
---|
1541 |
|
---|
1542 | <h3 class=fn>void <a name="setStyle"></a>QApplication::setStyle ( <a href="qstyle.html">QStyle</a> * style )<tt> [static]</tt>
|
---|
1543 | </h3>
|
---|
1544 | Sets the application's GUI style to <em>style</em>. Ownership of the style
|
---|
1545 | object is transferred to QApplication, so QApplication will delete
|
---|
1546 | the style object on application exit or when a new style is set.
|
---|
1547 | <p> Example usage:
|
---|
1548 | <pre>
|
---|
1549 | QApplication::<a href="#setStyle">setStyle</a>( new <a href="qwindowsstyle.html">QWindowsStyle</a> );
|
---|
1550 | </pre>
|
---|
1551 |
|
---|
1552 | <p> When switching application styles, the color palette is set back to
|
---|
1553 | the initial colors or the system defaults. This is necessary since
|
---|
1554 | certain styles have to adapt the color palette to be fully
|
---|
1555 | style-guide compliant.
|
---|
1556 | <p> <p>See also <a href="#style">style</a>(), <a href="qstyle.html">QStyle</a>, <a href="#setPalette">setPalette</a>(), and <a href="#desktopSettingsAware">desktopSettingsAware</a>().
|
---|
1557 |
|
---|
1558 | <p>Example: <a href="themes-example.html#x325">themes/themes.cpp</a>.
|
---|
1559 | <h3 class=fn><a href="qstyle.html">QStyle</a> * <a name="setStyle-2"></a>QApplication::setStyle ( const <a href="qstring.html">QString</a> & style )<tt> [static]</tt>
|
---|
1560 | </h3>
|
---|
1561 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
1562 | <p> Requests a <a href="qstyle.html">QStyle</a> object for <em>style</em> from the <a href="qstylefactory.html">QStyleFactory</a>.
|
---|
1563 | <p> The string must be one of the <a href="qstylefactory.html#keys">QStyleFactory::keys</a>(), typically one
|
---|
1564 | of "windows", "motif", "cde", "motifplus", "platinum", "sgi" and
|
---|
1565 | "compact". Depending on the platform, "windowsxp", "aqua" or
|
---|
1566 | "macintosh" may be available.
|
---|
1567 | <p> A later call to the QApplication constructor will override the
|
---|
1568 | requested style when a "-style" option is passed in as a commandline
|
---|
1569 | parameter.
|
---|
1570 | <p> Returns 0 if an unknown <em>style</em> is passed, otherwise the QStyle object
|
---|
1571 | returned is set as the application's GUI style.
|
---|
1572 |
|
---|
1573 | <h3 class=fn>void <a name="setWheelScrollLines"></a>QApplication::setWheelScrollLines ( int n )<tt> [static]</tt>
|
---|
1574 | </h3>
|
---|
1575 | Sets the number of lines to scroll when the mouse wheel is rotated
|
---|
1576 | to <em>n</em>.
|
---|
1577 | <p> If this number exceeds the number of visible lines in a certain
|
---|
1578 | widget, the widget should interpret the scroll operation as a
|
---|
1579 | single page up / page down operation instead.
|
---|
1580 | <p> <p>See also <a href="#wheelScrollLines">wheelScrollLines</a>().
|
---|
1581 |
|
---|
1582 | <h3 class=fn>void <a name="setWinStyleHighlightColor"></a>QApplication::setWinStyleHighlightColor ( const <a href="qcolor.html">QColor</a> & c )<tt> [static]</tt>
|
---|
1583 | </h3>
|
---|
1584 |
|
---|
1585 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
1586 | <p> Sets the color used to mark selections in windows style for all widgets
|
---|
1587 | in the application. Will repaint all widgets if the color is changed.
|
---|
1588 | <p> The default color is <tt>darkBlue</tt>.
|
---|
1589 | <p>See also <a href="#winStyleHighlightColor">winStyleHighlightColor</a>().
|
---|
1590 |
|
---|
1591 | <h3 class=fn>int <a name="startDragDistance"></a>QApplication::startDragDistance ()<tt> [static]</tt>
|
---|
1592 | </h3>
|
---|
1593 | If you support drag and drop in you application and a drag should
|
---|
1594 | start after a mouse click and after moving the mouse a certain
|
---|
1595 | distance, you should use the value which this method returns as the
|
---|
1596 | distance.
|
---|
1597 | <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
|
---|
1598 | <tt>currPos</tt>, you can find out if a drag should be started with code
|
---|
1599 | like this:
|
---|
1600 | <pre>
|
---|
1601 | if ( ( startPos - currPos ).manhattanLength() >
|
---|
1602 | QApplication::<a href="#startDragDistance">startDragDistance</a>() )
|
---|
1603 | startTheDrag();
|
---|
1604 | </pre>
|
---|
1605 |
|
---|
1606 | <p> Qt uses this value internally, e.g. in <a href="qfiledialog.html">QFileDialog</a>.
|
---|
1607 | <p> The default value is 4 pixels.
|
---|
1608 | <p> <p>See also <a href="#setStartDragDistance">setStartDragDistance</a>(), <a href="#startDragTime">startDragTime</a>(), and <a href="qpoint.html#manhattanLength">QPoint::manhattanLength</a>().
|
---|
1609 |
|
---|
1610 | <h3 class=fn>int <a name="startDragTime"></a>QApplication::startDragTime ()<tt> [static]</tt>
|
---|
1611 | </h3>
|
---|
1612 | If you support drag and drop in you application and a drag should
|
---|
1613 | start after a mouse click and after a certain time elapsed, you
|
---|
1614 | should use the value which this method returns as the delay (in ms).
|
---|
1615 | <p> Qt also uses this delay internally, e.g. in <a href="qtextedit.html">QTextEdit</a> and <a href="qlineedit.html">QLineEdit</a>,
|
---|
1616 | for starting a drag.
|
---|
1617 | <p> The default value is 500 ms.
|
---|
1618 | <p> <p>See also <a href="#setStartDragTime">setStartDragTime</a>() and <a href="#startDragDistance">startDragDistance</a>().
|
---|
1619 |
|
---|
1620 | <h3 class=fn>bool <a name="startingUp"></a>QApplication::startingUp ()<tt> [static]</tt>
|
---|
1621 | </h3>
|
---|
1622 | Returns TRUE if an application object has not been created yet;
|
---|
1623 | otherwise returns FALSE.
|
---|
1624 | <p> <p>See also <a href="#closingDown">closingDown</a>().
|
---|
1625 |
|
---|
1626 | <h3 class=fn><a href="qstyle.html">QStyle</a> & <a name="style"></a>QApplication::style ()<tt> [static]</tt>
|
---|
1627 | </h3>
|
---|
1628 | Returns the application's style object.
|
---|
1629 | <p> <p>See also <a href="#setStyle">setStyle</a>() and <a href="qstyle.html">QStyle</a>.
|
---|
1630 |
|
---|
1631 | <h3 class=fn>void <a name="syncX"></a>QApplication::syncX ()<tt> [static]</tt>
|
---|
1632 | </h3>
|
---|
1633 | Synchronizes with the X server in the X11 implementation. This
|
---|
1634 | normally takes some time. Does nothing on other platforms.
|
---|
1635 | <p> <p>See also <a href="#flushX">flushX</a>().
|
---|
1636 |
|
---|
1637 | <h3 class=fn>QWidgetList * <a name="topLevelWidgets"></a>QApplication::topLevelWidgets ()<tt> [static]</tt>
|
---|
1638 | </h3>
|
---|
1639 | Returns a list of the top level widgets in the application.
|
---|
1640 | <p> The list is created using <tt>new</tt> and must be deleted by the caller.
|
---|
1641 | <p> The list is empty (<a href="qptrlist.html#isEmpty">QPtrList::isEmpty</a>()) if there are no top level
|
---|
1642 | widgets.
|
---|
1643 | <p> Note that some of the top level widgets may be hidden, for example
|
---|
1644 | the tooltip if no tooltip is currently shown.
|
---|
1645 | <p> Example:
|
---|
1646 | <pre>
|
---|
1647 | // Show all hidden top level widgets.
|
---|
1648 | QWidgetList *list = QApplication::<a href="#topLevelWidgets">topLevelWidgets</a>();
|
---|
1649 | QWidgetListIt it( *list ); // iterate over the widgets
|
---|
1650 | <a href="qwidget.html">QWidget</a> * w;
|
---|
1651 | while ( (w=it.current()) != 0 ) { // for each top level widget...
|
---|
1652 | ++it;
|
---|
1653 | if ( !w-><a href="qwidget.html#isVisible">isVisible</a>() )
|
---|
1654 | w-><a href="qwidget.html#show">show</a>();
|
---|
1655 | }
|
---|
1656 | delete list; // delete the list, not the widgets
|
---|
1657 | </pre>
|
---|
1658 |
|
---|
1659 | <p> <b>Warning:</b> Delete the list as soon you have finished using it.
|
---|
1660 | The widgets in the list may be deleted by someone else at any time.
|
---|
1661 | <p> <p>See also <a href="#allWidgets">allWidgets</a>(), <a href="qwidget.html#isTopLevel-prop">QWidget::isTopLevel</a>, <a href="qwidget.html#visible-prop">QWidget::visible</a>, and <a href="qptrlist.html#isEmpty">QPtrList::isEmpty</a>().
|
---|
1662 |
|
---|
1663 | <h3 class=fn><a href="qstring.html">QString</a> <a name="translate"></a>QApplication::translate ( const char * context, const char * sourceText, const char * comment = 0, <a href="qapplication.html#Encoding-enum">Encoding</a> encoding = DefaultCodec ) const
|
---|
1664 | </h3><p><b>Note:</b> This function is <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
|
---|
1665 |
|
---|
1666 | Returns the translation text for <em>sourceText</em>, by querying the
|
---|
1667 | installed messages files. The message files are searched from the most
|
---|
1668 | recently installed message file back to the first installed message
|
---|
1669 | file.
|
---|
1670 | <p> <a href="qobject.html#tr">QObject::tr</a>() and <a href="qobject.html#trUtf8">QObject::trUtf8</a>() provide this functionality more
|
---|
1671 | conveniently.
|
---|
1672 | <p> <em>context</em> is typically a class name (e.g., "MyDialog") and
|
---|
1673 | <em>sourceText</em> is either English text or a short identifying text, if
|
---|
1674 | the output text will be very long (as for help texts).
|
---|
1675 | <p> <em>comment</em> is a disambiguating comment, for when the same <em>sourceText</em> is used in different roles within the same context. By
|
---|
1676 | default, it is null. <em>encoding</em> indicates the 8-bit encoding of
|
---|
1677 | character stings
|
---|
1678 | <p> See the <a href="qtranslator.html">QTranslator</a> documentation for more information about
|
---|
1679 | contexts and comments.
|
---|
1680 | <p> If none of the message files contain a translation for <em>sourceText</em> in <em>context</em>, this function returns a <a href="qstring.html">QString</a>
|
---|
1681 | equivalent of <em>sourceText</em>. The encoding of <em>sourceText</em> is
|
---|
1682 | specified by <em>encoding</em>; it defaults to <a href="#Encoding-enum">DefaultCodec</a>.
|
---|
1683 | <p> This function is not virtual. You can use alternative translation
|
---|
1684 | techniques by subclassing <a href="qtranslator.html">QTranslator</a>.
|
---|
1685 | <p> <b>Warning:</b> This method is reentrant only if all translators are
|
---|
1686 | installed <em>before</em> calling this method. Installing or removing
|
---|
1687 | translators while performing translations is not supported. Doing
|
---|
1688 | so will most likely result in crashes or other undesirable behavior.
|
---|
1689 | <p> <p>See also <a href="qobject.html#tr">QObject::tr</a>(), <a href="#installTranslator">installTranslator</a>(), and <a href="#defaultCodec">defaultCodec</a>().
|
---|
1690 |
|
---|
1691 | <h3 class=fn>bool <a name="tryLock"></a>QApplication::tryLock ()
|
---|
1692 | </h3>
|
---|
1693 | <p> Attempts to lock the Qt Library Mutex, and returns immediately. If
|
---|
1694 | the lock was obtained, this function returns TRUE. If another thread
|
---|
1695 | has locked the mutex, this function returns FALSE, instead of
|
---|
1696 | waiting for the lock to become available.
|
---|
1697 | <p> The mutex must be unlocked with <a href="#unlock">unlock</a>() before another thread can
|
---|
1698 | successfully lock it.
|
---|
1699 | <p> <p>See also <a href="#lock">lock</a>(), <a href="#unlock">unlock</a>(), and <a href="threads.html">Thread Support in Qt</a>.
|
---|
1700 |
|
---|
1701 | <h3 class=fn><a href="qapplication.html#Type-enum">Type</a> <a name="type"></a>QApplication::type () const
|
---|
1702 | </h3>
|
---|
1703 | Returns the type of application, Tty, GuiClient or GuiServer.
|
---|
1704 |
|
---|
1705 | <h3 class=fn>void <a name="unlock"></a>QApplication::unlock ( bool wakeUpGui = TRUE )
|
---|
1706 | </h3>
|
---|
1707 | <p> Unlock the Qt Library Mutex. If <em>wakeUpGui</em> is TRUE (the default),
|
---|
1708 | then the GUI thread will be woken with <a href="#wakeUpGuiThread">QApplication::wakeUpGuiThread</a>().
|
---|
1709 | <p> <p>See also <a href="#lock">lock</a>(), <a href="#locked">locked</a>(), and <a href="threads.html">Thread Support in Qt</a>.
|
---|
1710 |
|
---|
1711 | <h3 class=fn>void <a name="wakeUpGuiThread"></a>QApplication::wakeUpGuiThread ()
|
---|
1712 | </h3>
|
---|
1713 | <p> Wakes up the GUI thread.
|
---|
1714 | <p> <p>See also <a href="#guiThreadAwake">guiThreadAwake</a>() and <a href="threads.html">Thread Support in Qt</a>.
|
---|
1715 |
|
---|
1716 | <h3 class=fn>int <a name="wheelScrollLines"></a>QApplication::wheelScrollLines ()<tt> [static]</tt>
|
---|
1717 | </h3>
|
---|
1718 | Returns the number of lines to scroll when the mouse wheel is
|
---|
1719 | rotated.
|
---|
1720 | <p> <p>See also <a href="#setWheelScrollLines">setWheelScrollLines</a>().
|
---|
1721 |
|
---|
1722 | <h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="widgetAt"></a>QApplication::widgetAt ( int x, int y, bool child = FALSE )<tt> [static]</tt>
|
---|
1723 | </h3>
|
---|
1724 | Returns a pointer to the widget at global screen position <em>(x, y)</em>, or 0 if there is no Qt widget there.
|
---|
1725 | <p> If <em>child</em> is FALSE and there is a child widget at position <em>(x, y)</em>, the top-level widget containing it is returned. If <em>child</em>
|
---|
1726 | is TRUE the child widget at position <em>(x, y)</em> is returned.
|
---|
1727 | <p> This function is normally rather slow.
|
---|
1728 | <p> <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>().
|
---|
1729 |
|
---|
1730 | <h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="widgetAt-2"></a>QApplication::widgetAt ( const <a href="qpoint.html">QPoint</a> & pos, bool child = FALSE )<tt> [static]</tt>
|
---|
1731 | </h3>
|
---|
1732 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
1733 | <p> Returns a pointer to the widget at global screen position <em>pos</em>,
|
---|
1734 | or 0 if there is no Qt widget there.
|
---|
1735 | <p> If <em>child</em> is FALSE and there is a child widget at position <em>pos</em>, the top-level widget containing it is returned. If <em>child</em>
|
---|
1736 | is TRUE the child widget at position <em>pos</em> is returned.
|
---|
1737 |
|
---|
1738 | <h3 class=fn>bool <a name="winEventFilter"></a>QApplication::winEventFilter ( MSG * )<tt> [virtual]</tt>
|
---|
1739 | </h3>
|
---|
1740 | This virtual function is only implemented under Windows.
|
---|
1741 | <p> The message procedure calls this function for every message
|
---|
1742 | received. Reimplement this function if you want to process window
|
---|
1743 | messages that are not processed by Qt. If you don't want
|
---|
1744 | the event to be processed by Qt, then return TRUE; otherwise
|
---|
1745 | return FALSE.
|
---|
1746 |
|
---|
1747 | <h3 class=fn>void <a name="winFocus"></a>QApplication::winFocus ( <a href="qwidget.html">QWidget</a> * widget, bool gotFocus )
|
---|
1748 | </h3>
|
---|
1749 | This function is available only on Windows.
|
---|
1750 | <p> If <em>gotFocus</em> is TRUE, <em>widget</em> will become the active window.
|
---|
1751 | Otherwise the active window is reset to NULL.
|
---|
1752 |
|
---|
1753 | <h3 class=fn>const <a href="qcolor.html">QColor</a> & <a name="winStyleHighlightColor"></a>QApplication::winStyleHighlightColor ()<tt> [static]</tt>
|
---|
1754 | </h3>
|
---|
1755 |
|
---|
1756 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
1757 | <p> Returns the color used to mark selections in windows style.
|
---|
1758 | <p> <p>See also <a href="#setWinStyleHighlightColor">setWinStyleHighlightColor</a>().
|
---|
1759 |
|
---|
1760 | <h3 class=fn>bool <a name="x11EventFilter"></a>QApplication::x11EventFilter ( XEvent * )<tt> [virtual]</tt>
|
---|
1761 | </h3>
|
---|
1762 | This virtual function is only implemented under X11.
|
---|
1763 | <p> If you create an application that inherits QApplication and
|
---|
1764 | reimplement this function, you get direct access to all X events
|
---|
1765 | that the are received from the X server.
|
---|
1766 | <p> Return TRUE if you want to stop the event from being processed.
|
---|
1767 | Return FALSE for normal event dispatching.
|
---|
1768 | <p> <p>See also <a href="#x11ProcessEvent">x11ProcessEvent</a>().
|
---|
1769 |
|
---|
1770 | <h3 class=fn>int <a name="x11ProcessEvent"></a>QApplication::x11ProcessEvent ( XEvent * event )
|
---|
1771 | </h3>
|
---|
1772 | This function does the core processing of individual X
|
---|
1773 | <em>event</em>s, normally by dispatching Qt events to the right
|
---|
1774 | destination.
|
---|
1775 | <p> It returns 1 if the event was consumed by special handling, 0 if
|
---|
1776 | the <em>event</em> was consumed by normal handling, and -1 if the <em>event</em> was for an unrecognized widget.
|
---|
1777 | <p> <p>See also <a href="#x11EventFilter">x11EventFilter</a>().
|
---|
1778 |
|
---|
1779 | <hr><h2>Related Functions</h2>
|
---|
1780 | <h3 class=fn>void <a name="Q_ASSERT"></a>Q_ASSERT ( bool test )
|
---|
1781 | </h3>
|
---|
1782 |
|
---|
1783 | <p>
|
---|
1784 | <p> Prints a warning message containing the source code file name and
|
---|
1785 | line number if <em>test</em> is FALSE.
|
---|
1786 | <p> This is really a macro defined in <a href="qglobal-h.html">qglobal.h</a>.
|
---|
1787 | <p> Q_ASSERT is useful for testing pre- and post-conditions.
|
---|
1788 | <p> Example:
|
---|
1789 | <pre>
|
---|
1790 | //
|
---|
1791 | // File: div.cpp
|
---|
1792 | //
|
---|
1793 |
|
---|
1794 | #include <<a href="qglobal-h.html">qglobal.h</a>>
|
---|
1795 |
|
---|
1796 | int divide( int a, int b )
|
---|
1797 | {
|
---|
1798 | <a href="#Q_ASSERT">Q_ASSERT</a>( b != 0 ); // this is line 9
|
---|
1799 | return a/b;
|
---|
1800 | }
|
---|
1801 | </pre>
|
---|
1802 |
|
---|
1803 | <p> If <tt>b</tt> is zero, the Q_ASSERT statement will output the following
|
---|
1804 | message using the <a href="#qWarning">qWarning</a>() function:
|
---|
1805 | <pre>
|
---|
1806 | ASSERT: "b != 0" in div.cpp (9)
|
---|
1807 | </pre>
|
---|
1808 |
|
---|
1809 | <p> <p>See also <a href="#qWarning">qWarning</a>() and <a href="debug.html">Debugging</a>.
|
---|
1810 |
|
---|
1811 | <h3 class=fn>void <a name="Q_CHECK_PTR"></a>Q_CHECK_PTR ( void * p )
|
---|
1812 | </h3>
|
---|
1813 |
|
---|
1814 | <p>
|
---|
1815 | <p> If <em>p</em> is 0, prints a warning message containing the source code file
|
---|
1816 | name and line number, saying that the program ran out of memory.
|
---|
1817 | <p> This is really a macro defined in <a href="qglobal-h.html">qglobal.h</a>.
|
---|
1818 | <p> Example:
|
---|
1819 | <pre>
|
---|
1820 | int *a;
|
---|
1821 |
|
---|
1822 | <a href="#Q_CHECK_PTR">Q_CHECK_PTR</a>( a = new int[80] ); // WRONG!
|
---|
1823 |
|
---|
1824 | a = new (nothrow) int[80]; // Right
|
---|
1825 | <a href="#Q_CHECK_PTR">Q_CHECK_PTR</a>( a );
|
---|
1826 | </pre>
|
---|
1827 |
|
---|
1828 | <p> <p>See also <a href="#qWarning">qWarning</a>() and <a href="debug.html">Debugging</a>.
|
---|
1829 |
|
---|
1830 | <h3 class=fn>void <a name="qAddPostRoutine"></a>qAddPostRoutine ( QtCleanUpFunction p )
|
---|
1831 | </h3>
|
---|
1832 |
|
---|
1833 | <p> Adds a global routine that will be called from the QApplication
|
---|
1834 | destructor. This function is normally used to add cleanup routines
|
---|
1835 | for program-wide functionality.
|
---|
1836 | <p> The function given by <em>p</em> should take no arguments and return
|
---|
1837 | nothing, like this:
|
---|
1838 | <pre>
|
---|
1839 | static int *global_ptr = 0;
|
---|
1840 |
|
---|
1841 | static void cleanup_ptr()
|
---|
1842 | {
|
---|
1843 | delete [] global_ptr;
|
---|
1844 | global_ptr = 0;
|
---|
1845 | }
|
---|
1846 |
|
---|
1847 | void init_ptr()
|
---|
1848 | {
|
---|
1849 | global_ptr = new int[100]; // allocate data
|
---|
1850 | <a href="#qAddPostRoutine">qAddPostRoutine</a>( cleanup_ptr ); // delete later
|
---|
1851 | }
|
---|
1852 | </pre>
|
---|
1853 |
|
---|
1854 | <p> Note that for an application- or module-wide cleanup,
|
---|
1855 | <a href="#qAddPostRoutine">qAddPostRoutine</a>() is often not suitable. People have a tendency to
|
---|
1856 | make such modules dynamically loaded, and then unload those modules
|
---|
1857 | long before the QApplication destructor is called, for example.
|
---|
1858 | <p> For modules and libraries, using a reference-counted initialization
|
---|
1859 | manager or Qt' parent-child delete mechanism may be better. Here is
|
---|
1860 | an example of a private class which uses the parent-child mechanism
|
---|
1861 | to call a cleanup function at the right time:
|
---|
1862 | <p> <pre>
|
---|
1863 | class MyPrivateInitStuff: public <a href="qobject.html">QObject</a> {
|
---|
1864 | private:
|
---|
1865 | MyPrivateInitStuff( <a href="qobject.html">QObject</a> * parent ): <a href="qobject.html">QObject</a>( parent) {
|
---|
1866 | // initialization goes here
|
---|
1867 | }
|
---|
1868 | MyPrivateInitStuff * p;
|
---|
1869 |
|
---|
1870 | public:
|
---|
1871 | static MyPrivateInitStuff * initStuff( <a href="qobject.html">QObject</a> * parent ) {
|
---|
1872 | if ( !p )
|
---|
1873 | p = new MyPrivateInitStuff( parent );
|
---|
1874 | return p;
|
---|
1875 | }
|
---|
1876 |
|
---|
1877 | ~MyPrivateInitStuff() {
|
---|
1878 | // cleanup (the "post routine") goes here
|
---|
1879 | }
|
---|
1880 | }
|
---|
1881 | </pre>
|
---|
1882 |
|
---|
1883 | <p> By selecting the right parent widget/object, this can often be made
|
---|
1884 | to clean up the module's data at the exact right moment.
|
---|
1885 |
|
---|
1886 | <h3 class=fn>void <a name="qDebug"></a>qDebug ( const char * msg, ... )
|
---|
1887 | </h3>
|
---|
1888 |
|
---|
1889 | <p>
|
---|
1890 | <p> Prints a debug message <em>msg</em>, or calls the message handler (if it
|
---|
1891 | has been installed).
|
---|
1892 | <p> This function takes a format string and a list of arguments,
|
---|
1893 | similar to the C printf() function.
|
---|
1894 | <p> Example:
|
---|
1895 | <pre>
|
---|
1896 | <a href="#qDebug">qDebug</a>( "my window handle = %x", myWidget->id() );
|
---|
1897 | </pre>
|
---|
1898 |
|
---|
1899 | <p> Under X11, the text is printed to stderr. Under Windows, the text
|
---|
1900 | is sent to the debugger.
|
---|
1901 | <p> <b>Warning:</b> The internal buffer is limited to 8196 bytes (including
|
---|
1902 | the '\0'-terminator).
|
---|
1903 | <p> <b>Warning:</b> Passing (const char *)0 as argument to qDebug might lead
|
---|
1904 | to crashes on certain platforms due to the platforms printf implementation.
|
---|
1905 | <p> <p>See also <a href="#qWarning">qWarning</a>(), <a href="#qFatal">qFatal</a>(), <a href="#qInstallMsgHandler">qInstallMsgHandler</a>(), and <a href="debug.html">Debugging</a>.
|
---|
1906 |
|
---|
1907 | <h3 class=fn>void <a name="qFatal"></a>qFatal ( const char * msg, ... )
|
---|
1908 | </h3>
|
---|
1909 |
|
---|
1910 | <p>
|
---|
1911 | <p> Prints a fatal error message <em>msg</em> and exits, or calls the
|
---|
1912 | message handler (if it has been installed).
|
---|
1913 | <p> This function takes a format string and a list of arguments,
|
---|
1914 | similar to the C printf() function.
|
---|
1915 | <p> Example:
|
---|
1916 | <pre>
|
---|
1917 | int divide( int a, int b )
|
---|
1918 | {
|
---|
1919 | if ( b == 0 ) // program error
|
---|
1920 | <a href="#qFatal">qFatal</a>( "divide: cannot divide by zero" );
|
---|
1921 | return a/b;
|
---|
1922 | }
|
---|
1923 | </pre>
|
---|
1924 |
|
---|
1925 | <p> Under X11, the text is printed to stderr. Under Windows, the text
|
---|
1926 | is sent to the debugger.
|
---|
1927 | <p> <b>Warning:</b> The internal buffer is limited to 8196 bytes (including
|
---|
1928 | the '\0'-terminator).
|
---|
1929 | <p> <b>Warning:</b> Passing (const char *)0 as argument to qFatal might lead
|
---|
1930 | to crashes on certain platforms due to the platforms printf implementation.
|
---|
1931 | <p> <p>See also <a href="#qDebug">qDebug</a>(), <a href="#qWarning">qWarning</a>(), <a href="#qInstallMsgHandler">qInstallMsgHandler</a>(), and <a href="debug.html">Debugging</a>.
|
---|
1932 |
|
---|
1933 | <h3 class=fn>QtMsgHandler <a name="qInstallMsgHandler"></a>qInstallMsgHandler ( QtMsgHandler h )
|
---|
1934 | </h3>
|
---|
1935 |
|
---|
1936 | <p> Installs a Qt message handler <em>h</em>. Returns a pointer to the
|
---|
1937 | message handler previously defined.
|
---|
1938 | <p> The message handler is a function that prints out debug messages,
|
---|
1939 | warnings and fatal error messages. The Qt library (debug version)
|
---|
1940 | contains hundreds of warning messages that are printed when
|
---|
1941 | internal errors (usually invalid function arguments) occur. If you
|
---|
1942 | implement your own message handler, you get total control of these
|
---|
1943 | messages.
|
---|
1944 | <p> The default message handler prints the message to the standard
|
---|
1945 | output under X11 or to the debugger under Windows. If it is a
|
---|
1946 | fatal message, the application aborts immediately.
|
---|
1947 | <p> Only one message handler can be defined, since this is usually
|
---|
1948 | done on an application-wide basis to control debug output.
|
---|
1949 | <p> To restore the message handler, call <tt>qInstallMsgHandler(0)</tt>.
|
---|
1950 | <p> Example:
|
---|
1951 | <pre>
|
---|
1952 | #include <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
1953 | #include <stdio.h>
|
---|
1954 | #include <stdlib.h>
|
---|
1955 |
|
---|
1956 | void myMessageOutput( QtMsgType type, const char *msg )
|
---|
1957 | {
|
---|
1958 | switch ( type ) {
|
---|
1959 | case QtDebugMsg:
|
---|
1960 | fprintf( stderr, "Debug: %s\n", msg );
|
---|
1961 | break;
|
---|
1962 | case QtWarningMsg:
|
---|
1963 | fprintf( stderr, "Warning: %s\n", msg );
|
---|
1964 | break;
|
---|
1965 | case QtFatalMsg:
|
---|
1966 | fprintf( stderr, "Fatal: %s\n", msg );
|
---|
1967 | abort(); // deliberately core dump
|
---|
1968 | }
|
---|
1969 | }
|
---|
1970 |
|
---|
1971 | int main( int argc, char **argv )
|
---|
1972 | {
|
---|
1973 | <a href="#qInstallMsgHandler">qInstallMsgHandler</a>( myMessageOutput );
|
---|
1974 | QApplication a( argc, argv );
|
---|
1975 | ...
|
---|
1976 | return a.<a href="#exec">exec</a>();
|
---|
1977 | }
|
---|
1978 | </pre>
|
---|
1979 |
|
---|
1980 | <p> <p>See also <a href="#qDebug">qDebug</a>(), <a href="#qWarning">qWarning</a>(), <a href="#qFatal">qFatal</a>(), and <a href="debug.html">Debugging</a>.
|
---|
1981 |
|
---|
1982 | <h3 class=fn>bool <a name="qSysInfo"></a>qSysInfo ( int * wordSize, bool * bigEndian )
|
---|
1983 | </h3>
|
---|
1984 |
|
---|
1985 | <p> Obtains information about the system.
|
---|
1986 | <p> The system's word size in bits (typically 32) is returned in <em>*wordSize</em>. The <em>*bigEndian</em> is set to TRUE if this is a big-endian
|
---|
1987 | machine, or to FALSE if this is a little-endian machine.
|
---|
1988 | <p> In debug mode, this function calls <a href="#qFatal">qFatal</a>() with a message if the
|
---|
1989 | computer is truly weird (i.e. different endianness for 16 bit and
|
---|
1990 | 32 bit integers); in release mode it returns FALSE.
|
---|
1991 |
|
---|
1992 | <h3 class=fn>void <a name="qSystemWarning"></a>qSystemWarning ( const char * msg, int code )
|
---|
1993 | </h3>
|
---|
1994 |
|
---|
1995 | <p> Prints the message <em>msg</em> and uses <em>code</em> to get a system specific
|
---|
1996 | error message. When <em>code</em> is -1 (the default), the system's last
|
---|
1997 | error code will be used if possible. Use this method to handle
|
---|
1998 | failures in platform specific API calls.
|
---|
1999 | <p> This function does nothing when Qt is built with <tt>QT_NO_DEBUG</tt>
|
---|
2000 | defined.
|
---|
2001 |
|
---|
2002 | <h3 class=fn>const char * <a name="qVersion"></a>qVersion ()
|
---|
2003 | </h3>
|
---|
2004 |
|
---|
2005 | <p> Returns the Qt version number as a string, for example, "2.3.0" or
|
---|
2006 | "3.0.5".
|
---|
2007 | <p> The <tt>QT_VERSION</tt> define has the numeric value in the form:
|
---|
2008 | 0xmmiibb (m = major, i = minor, b = bugfix). For example, Qt
|
---|
2009 | 3.0.5's <tt>QT_VERSION</tt> is 0x030005.
|
---|
2010 |
|
---|
2011 | <h3 class=fn>void <a name="qWarning"></a>qWarning ( const char * msg, ... )
|
---|
2012 | </h3>
|
---|
2013 |
|
---|
2014 | <p>
|
---|
2015 | <p> Prints a warning message <em>msg</em>, or calls the message handler (if
|
---|
2016 | it has been installed).
|
---|
2017 | <p> This function takes a format string and a list of arguments,
|
---|
2018 | similar to the C printf() function.
|
---|
2019 | <p> Example:
|
---|
2020 | <pre>
|
---|
2021 | void f( int c )
|
---|
2022 | {
|
---|
2023 | if ( c > 200 )
|
---|
2024 | <a href="#qWarning">qWarning</a>( "f: bad argument, c == %d", c );
|
---|
2025 | }
|
---|
2026 | </pre>
|
---|
2027 |
|
---|
2028 | <p> Under X11, the text is printed to stderr. Under Windows, the text
|
---|
2029 | is sent to the debugger.
|
---|
2030 | <p> <b>Warning:</b> The internal buffer is limited to 8196 bytes (including
|
---|
2031 | the '\0'-terminator).
|
---|
2032 | <p> <b>Warning:</b> Passing (const char *)0 as argument to qWarning might lead
|
---|
2033 | to crashes on certain platforms due to the platforms printf implementation.
|
---|
2034 | <p> <p>See also <a href="#qDebug">qDebug</a>(), <a href="#qFatal">qFatal</a>(), <a href="#qInstallMsgHandler">qInstallMsgHandler</a>(), and <a href="debug.html">Debugging</a>.
|
---|
2035 |
|
---|
2036 | <!-- eof -->
|
---|
2037 | <hr><p>
|
---|
2038 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
2039 | Copyright © 1995-2007
|
---|
2040 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
2041 | <table width=100% cellspacing=0 border=0><tr>
|
---|
2042 | <td>Copyright © 2007
|
---|
2043 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
2044 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
2045 | </table></div></address></body>
|
---|
2046 | </html>
|
---|