<tdalign="right"valign="center"><imgsrc="logo32.png"align="right"width="64"height="32"border="0"></td></tr></table><h1align=center>QApplication Class Reference</h1>
<p>The QApplication class manages the GUI application's control
The QApplication class manages the GUI application's control
flow and main settings.
<p>
<p> It contains the main event loop, where all events from the window
system and other sources are processed and dispatched. It also
handles the application's initialization and finalization, and
provides session management. It also handles most system-wide and
application-wide settings.
<p> For any GUI application that uses Qt, there is precisely one
QApplication object, no matter whether the application has 0, 1, 2
or more windows at any time.
<p> The QApplication object is accessible through the global pointer <tt>qApp</tt>. Its main areas of responsibility are:
<ul>
<p><li> It initializes the application with the user's desktop settings
such as <ahref="#palette">palette</a>(), <ahref="#font">font</a>() and <ahref="#doubleClickInterval">doubleClickInterval</a>(). It keeps track
of these properties in case the user changes the desktop globally, for
example through some kind of control panel.
<p><li> It performs event handling, meaning that it receives events
from the underlying window system and dispatches them to the relevant
widgets. By using <ahref="#sendEvent">sendEvent</a>() and <ahref="#postEvent">postEvent</a>() you can send your own
events to widgets.
<p><li> It parses common command line arguments and sets its internal
state accordingly. See the <ahref="#QApplication">constructor documentation</a> below for more details about this.
<p><li> It defines the application's look and feel, which is
encapsulated in a <ahref="qstyle.html">QStyle</a> object. This can be changed at runtime
with <ahref="#setStyle">setStyle</a>().
<p><li> It specifies how the application is to allocate colors.
See <ahref="#setColorSpec">setColorSpec</a>() for details.
<p><li> It provides <ahref="i18n.html#localization">localization</a> of strings that are visible to the user
via <ahref="#translate">translate</a>().
<p><li> It provides some magical objects like the <ahref="#desktop">desktop</a>() and the
<ahref="#clipboard">clipboard</a>().
<p><li> It knows about the application's windows. You can ask which
widget is at a certain position using <ahref="#widgetAt">widgetAt</a>(), get a list of
<ahref="#topLevelWidgets">topLevelWidgets</a>() and <ahref="#closeAllWindows">closeAllWindows</a>(), etc.
<p><li> It manages the application's mouse cursor handling,
see <ahref="#setOverrideCursor">setOverrideCursor</a>() and <ahref="#setGlobalMouseTracking">setGlobalMouseTracking</a>().
<p><li> On the X window system, it provides functions to flush and sync
the communication stream, see <ahref="#flushX">flushX</a>() and <ahref="#syncX">syncX</a>().
<p><li> It provides support for sophisticated <ahref="session.html">session management</a>. This makes it possible
for applications to terminate gracefully when the user logs out, to
cancel a shutdown process if termination isn't possible and even to
preserve the entire application's state for a future session. See
<ahref="#isSessionRestored">isSessionRestored</a>(), <ahref="#sessionId">sessionId</a>() and <ahref="#commitData">commitData</a>() and <ahref="#saveState">saveState</a>()
for details.
<p></ul>
<p> The <ahref="simple-application.html">Application walk-through
example</a> contains a typical complete main() that does the usual
things with QApplication.
<p> Since the QApplication object does so much initialization, it
<b>must</b> be created before any other objects related to the user
interface are created.
<p> Since it also deals with common command line arguments, it is
usually a good idea to create it <em>before</em> any interpretation or
modification of <tt>argv</tt> is done in the application itself. (Note
also that for X11, <ahref="#setMainWidget">setMainWidget</a>() may change the main widget
according to the <tt>-geometry</tt> option. To preserve this
functionality, you must set your defaults before setMainWidget() and
<p> This enum type defines the 8-bit encoding of character string
arguments to <ahref="#translate">translate</a>():
<ul>
<li><tt>QApplication::DefaultCodec</tt> - the encoding specified by
<ahref="qtextcodec.html#codecForTr">QTextCodec::codecForTr</a>() (Latin-1 if none has been set)
<li><tt>QApplication::UnicodeUTF8</tt> - UTF-8
</ul><p><p>See also <ahref="qobject.html#tr">QObject::tr</a>(), <ahref="qobject.html#trUtf8">QObject::trUtf8</a>(), and <ahref="qstring.html#fromUtf8">QString::fromUtf8</a>().
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
the default Visual and Colormap contexts.
<p><b>Warning:</b> Qt only supports TrueColor visuals at depths higher than 8
<p> A popup widget is a special top level widget that sets the <ahref="qt.html#WidgetFlags-enum">WType_Popup</a> widget flag, e.g. the <ahref="qpopupmenu.html">QPopupMenu</a> widget. When the
application opens a popup widget, all events are sent to the popup.
Normal widgets and modal widgets cannot be accessed before the popup
widget is closed.
<p> Only other popup widgets may be opened when a popup widget is shown.
The popup widgets are organized in a stack. This function returns
the active popup widget at the top of the stack.
<p><p>See also <ahref="#activeModalWidget">activeModalWidget</a>() and <ahref="#topLevelWidgets">topLevelWidgets</a>().
<p> Returns the application top-level window that has the keyboard input
focus, or 0 if no application window has the focus. Note that
there might be an <ahref="#activeWindow">activeWindow</a>() even if there is no <ahref="#focusWidget">focusWidget</a>(),
for example if no widget in that window accepts key events.
<p><p>See also <ahref="qwidget.html#setFocus">QWidget::setFocus</a>(), <ahref="qwidget.html#focus-prop">QWidget::focus</a>, and <ahref="#focusWidget">focusWidget</a>().
Append <em>path</em> to the end of the library path list. If <em>path</em> is
empty or already in the path list, the path list is not changed.
<p> The default path list consists of a single entry, the installation
directory for plugins. The default installation directory for plugins
is <tt>INSTALL/plugins</tt>, where <tt>INSTALL</tt> is the directory where Qt was
installed.
<p><p>See also <ahref="#removeLibraryPath">removeLibraryPath</a>(), <ahref="#libraryPaths">libraryPaths</a>(), and <ahref="#setLibraryPaths">setLibraryPaths</a>().
QWidgetListIt it( *list ); // iterate over the widgets
<ahref="qwidget.html">QWidget</a> * w;
while ( (w=it.current()) != 0 ) { // for each widget...
++it;
w-><ahref="qwidget.html#update">update</a>();
}
delete list; // delete the list, not the widgets
</pre>
<p> The QWidgetList class is defined in the <tt>qwidgetlist.h</tt> header
file.
<p><b>Warning:</b> Delete the list as soon as you have finished using it.
The widgets in the list may be deleted by someone else at any time.
<p><p>See also <ahref="#topLevelWidgets">topLevelWidgets</a>(), <ahref="qwidget.html#visible-prop">QWidget::visible</a>, and <ahref="qptrlist.html#isEmpty">QPtrList::isEmpty</a>().
Returns a pointer to the application global clipboard.
<p>Examples: <ahref="regexptester-example.html#x2468">regexptester/regexptester.cpp</a> and <ahref="showimg-example.html#x1308">showimg/showimg.cpp</a>.
<p> The windows are closed in random order, until one window does not
accept the close event.
<p><p>See also <ahref="qwidget.html#close">QWidget::close</a>(), <ahref="qwidget.html#closeEvent">QWidget::closeEvent</a>(), <ahref="#lastWindowClosed">lastWindowClosed</a>(), <ahref="#quit">quit</a>(), <ahref="#topLevelWidgets">topLevelWidgets</a>(), and <ahref="qwidget.html#isTopLevel-prop">QWidget::isTopLevel</a>.
<p>
<p>Examples: <ahref="qaction-application-example.html#x1127">action/application.cpp</a>, <ahref="simple-application-example.html#x1544">application/application.cpp</a>, <ahref="helpviewer-example.html#x980">helpviewer/helpwindow.cpp</a>, <ahref="mdi-example.html#x2020">mdi/application.cpp</a>, and <ahref="qwerty-example.html#x358">qwerty/qwerty.cpp</a>.
<p> This function deals with <ahref="session.html">session
management</a>. It is invoked when the <ahref="qsessionmanager.html">QSessionManager</a> wants the
application to commit all its data.
<p> Usually this means saving all open files, after getting
permission from the user. Furthermore you may want to provide a means
by which the user can cancel the shutdown.
<p> Note that you should not exit the application within this function.
Instead, the session manager may or may not do this afterwards,
depending on the context.
<p><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.
See <ahref="qsessionmanager.html#allowsInteraction">QSessionManager::allowsInteraction</a>() and
<ahref="qsessionmanager.html#allowsErrorInteraction">QSessionManager::allowsErrorInteraction</a>() for details and example
usage.
<p> The default implementation requests interaction and sends a close
event to all visible top level widgets. If any event was
rejected, the shutdown is canceled.
<p><p>See also <ahref="#isSessionRestored">isSessionRestored</a>(), <ahref="#sessionId">sessionId</a>(), <ahref="#saveState">saveState</a>(), and <ahref="session.html">the Session Management overview</a>.
Enters the main event loop and waits until <ahref="#exit">exit</a>() is called or the
main widget is destroyed, and returns the value that was set to
exit() (which is 0 if exit() is called via <ahref="#quit">quit</a>()).
<p> It is necessary to call this function to start event handling. The
main event loop receives events from the window system and
dispatches these to the application widgets.
<p> Generally speaking, no user interaction can take place before
calling <ahref="#exec">exec</a>(). As a special case, modal widgets like <ahref="qmessagebox.html">QMessageBox</a>
can be used before calling exec(), because modal widgets call
exec() to start a local event loop.
<p> To make your application perform idle processing, i.e. executing a
special function whenever there are no pending events, use a
<ahref="qtimer.html">QTimer</a> with 0 timeout. More advanced idle processing schemes can
be achieved using <ahref="#processEvents">processEvents</a>().
<p><p>See also <ahref="#quit">quit</a>(), <ahref="#exit">exit</a>(), <ahref="#processEvents">processEvents</a>(), and <ahref="#setMainWidget">setMainWidget</a>().
<p>Examples: <ahref="helpsystem-example.html#x2700">helpsystem/main.cpp</a>, <ahref="qdialog.html#x2132">life/main.cpp</a>, <ahref="archivesearch-example.html#x486">network/archivesearch/main.cpp</a>, <ahref="ftpclient-example.html#x777">network/ftpclient/main.cpp</a>, <ahref="qaxserver-example-opengl.html#x2731">opengl/main.cpp</a>, <ahref="tutorial1-01.html#x2283">t1/main.cpp</a>, and <ahref="tutorial1-04.html#x2303">t4/main.cpp</a>.
<p> After this function has been called, the application leaves the main
event loop and returns from the call to <ahref="#exec">exec</a>(). The exec() function
returns <em>retcode</em>.
<p> By convention, a <em>retcode</em> of 0 means success, and any non-zero
value indicates an error.
<p> Note that unlike the C library function of the same name, this
function <em>does</em> return to the caller -- it is event processing that
stops.
<p><p>See also <ahref="#quit">quit</a>() and <ahref="#exec">exec</a>().
<p>Examples: <ahref="canvas-chart-example.html#x2875">chart/chartform.cpp</a>, <ahref="extension-dialog-example.html#x2865">extension/mainform.ui.h</a>, and <ahref="picture-example.html#x106">picture/picture.cpp</a>.
<p> If you are doing graphical changes inside a loop that does not
return to the event loop on asynchronous window systems like X11
or double buffered window systems like MacOS X, and you want to
visualize these changes immediately (e.g. Splash Screens), call
this function.
<p><p>See also <ahref="#flushX">flushX</a>(), <ahref="#sendPostedEvents">sendPostedEvents</a>(), and <ahref="qpainter.html#flush">QPainter::flush</a>().
<p> Returns the application widget that has the keyboard input focus, or
0 if no widget in this application has the focus.
<p><p>See also <ahref="qwidget.html#setFocus">QWidget::setFocus</a>(), <ahref="qwidget.html#focus-prop">QWidget::focus</a>, and <ahref="#activeWindow">activeWindow</a>().
Returns the default font for the widget <em>w</em>, or the default
application font if <em>w</em> is 0.
<p><p>See also <ahref="#setFont">setFont</a>(), <ahref="#fontMetrics">fontMetrics</a>(), and <ahref="qwidget.html#font-prop">QWidget::font</a>.
<p>Examples: <ahref="qfd-example.html#x1979">qfd/fontdisplayer.cpp</a>, <ahref="themes-example.html#x264">themes/metal.cpp</a>, and <ahref="themes-example.html#x321">themes/themes.cpp</a>.
Returns display (screen) font metrics for the application font.
<p><p>See also <ahref="#font">font</a>(), <ahref="#setFont">setFont</a>(), <ahref="qwidget.html#fontMetrics">QWidget::fontMetrics</a>(), and <ahref="qpainter.html#fontMetrics">QPainter::fontMetrics</a>().
Adds the message file <em>mf</em> to the list of message files to be used
for translations.
<p> Multiple message files can be installed. Translations are searched
for in the last installed message file, then the one from last, and
so on, back to the first installed message file. The search stops as
soon as a matching translation is found.
<p><p>See also <ahref="#removeTranslator">removeTranslator</a>(), <ahref="#translate">translate</a>(), and <ahref="qtranslator.html#load">QTranslator::load</a>().
<p> This signal is emitted when the user has closed the last
top level window.
<p> The signal is very useful when your application has many top level
widgets but no main widget. You can then connect it to the <ahref="#quit">quit</a>()
slot.
<p> For convenience, this signal is <em>not</em> emitted for transient top level
widgets such as popup menus and dialogs.
<p><p>See also <ahref="#mainWidget">mainWidget</a>(), <ahref="#topLevelWidgets">topLevelWidgets</a>(), <ahref="qwidget.html#isTopLevel-prop">QWidget::isTopLevel</a>, and <ahref="qwidget.html#close">QWidget::close</a>().
<p>Examples: <ahref="addressbook-example.html#x608">addressbook/main.cpp</a>, <ahref="extension-dialog-example.html#x2867">extension/main.cpp</a>, <ahref="helpviewer-example.html#x1039">helpviewer/main.cpp</a>, <ahref="mdi-example.html#x2096">mdi/main.cpp</a>, <ahref="archivesearch-example.html#x487">network/archivesearch/main.cpp</a>, <ahref="qwerty-example.html#x416">qwerty/main.cpp</a>, and <ahref="regexptester-example.html#x2509">regexptester/main.cpp</a>.
Returns a list of paths that the application will search when
dynamically loading libraries.
The installation directory for plugins is the only entry if no
paths have been set. The default installation directory for plugins
is <tt>INSTALL/plugins</tt>, where <tt>INSTALL</tt> is the directory where Qt was
installed. The directory of the application executable (NOT the
working directory) is also added to the plugin paths.
<p> If you want to iterate over the list, you should iterate over a
copy, e.g.
<pre>
<ahref="qstringlist.html">QStringList</a> list = app.libraryPaths();
QStringList::Iterator it = list.<ahref="qvaluelist.html#begin">begin</a>();
while( it != list.<ahref="qvaluelist.html#end">end</a>() ) {
myProcessing( *it );
++it;
}
</pre>
<p> See the <ahref="plugins-howto.html">plugins documentation</a> for a
description of how the library paths are used.
<p><p>See also <ahref="#setLibraryPaths">setLibraryPaths</a>(), <ahref="#addLibraryPath">addLibraryPath</a>(), <ahref="#removeLibraryPath">removeLibraryPath</a>(), and <ahref="qlibrary.html">QLibrary</a>.
<p> If a widget is passed in <em>w</em>, the default palette for the
widget's class is returned. This may or may not be the application
palette. In most cases there isn't a special palette for certain
types of widgets, but one notable exception is the popup menu under
Windows, if the user has defined a special background color for
menus in the display settings.
<p><p>See also <ahref="#setPalette">setPalette</a>() and <ahref="qwidget.html#palette-prop">QWidget::palette</a>.
<p>Examples: <ahref="desktop-example.html#x1723">desktop/desktop.cpp</a>, <ahref="themes-example.html#x265">themes/metal.cpp</a>, and <ahref="themes-example.html#x186">themes/wood.cpp</a>.
Initialization of the appearance of the widget <em>w</em><em>before</em> it is first
shown.
<p> Usually widgets call this automatically when they are polished. It
may be used to do some style-based central customization of widgets.
<p> Note that you are not limited to the public functions of <ahref="qwidget.html">QWidget</a>.
Instead, based on meta information like <ahref="qobject.html#className">QObject::className</a>() you are
able to customize any kind of widget.
<p><p>See also <ahref="qstyle.html#polish">QStyle::polish</a>(), <ahref="qwidget.html#polish">QWidget::polish</a>(), <ahref="#setPalette">setPalette</a>(), and <ahref="#setFont">setFont</a>().
Processes pending events, for 3 seconds or until there are no more
events to process, whichever is shorter.
<p> You can call this function occasionally when your program is busy
performing a long operation (e.g. copying a file).
<p><p>See also <ahref="#exec">exec</a>(), <ahref="qtimer.html">QTimer</a>, and <ahref="qeventloop.html#processEvents">QEventLoop::processEvents</a>().
<p>Examples: <ahref="fileiconview-example.html#x808">fileiconview/qfileiconview.cpp</a> and <ahref="ftpclient-example.html#x778">network/ftpclient/main.cpp</a>.
<p><p>See also <ahref="#exit">exit</a>(), <ahref="#aboutToQuit">aboutToQuit</a>(), <ahref="#lastWindowClosed">lastWindowClosed</a>(), and <ahref="qaction.html">QAction</a>.
<p>Examples: <ahref="addressbook-example.html#x609">addressbook/main.cpp</a>, <ahref="mdi-example.html#x2097">mdi/main.cpp</a>, <ahref="archivesearch-example.html#x488">network/archivesearch/main.cpp</a>, <ahref="regexptester-example.html#x2510">regexptester/main.cpp</a>, <ahref="tutorial1-02.html#x2288">t2/main.cpp</a>, <ahref="tutorial1-04.html#x2304">t4/main.cpp</a>, and <ahref="tutorial1-06.html#x2321">t6/main.cpp</a>.
Removes <em>path</em> from the library path list. If <em>path</em> is empty or not
in the path list, the list is not changed.
<p><p>See also <ahref="#addLibraryPath">addLibraryPath</a>(), <ahref="#libraryPaths">libraryPaths</a>(), and <ahref="#setLibraryPaths">setLibraryPaths</a>().
Removes the message file <em>mf</em> from the list of message files used by
this application. (It does not delete the message file from the file
system.)
<p><p>See also <ahref="#installTranslator">installTranslator</a>(), <ahref="#translate">translate</a>(), and <ahref="qobject.html#tr">QObject::tr</a>().
<p> This function deals with <ahref="session.html">session
management</a>. It is invoked when the
<ahref="qsessionmanager.html">session manager</a> wants the application
to preserve its state for a future session.
<p> For example, a text editor would create a temporary file that
includes the current contents of its edit buffers, the location of
the cursor and other aspects of the current editing session.
<p> Note that you should never exit the application within this
function. Instead, the session manager may or may not do this
afterwards, depending on the context. Futhermore, most session
managers will very likely request a saved state immediately after
the application has been started. This permits the session manager
to learn about the application's restart policy.
<p><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.
See <ahref="qsessionmanager.html#allowsInteraction">QSessionManager::allowsInteraction</a>() and
<ahref="qsessionmanager.html#allowsErrorInteraction">QSessionManager::allowsErrorInteraction</a>() for details.
<p><p>See also <ahref="#isSessionRestored">isSessionRestored</a>(), <ahref="#sessionId">sessionId</a>(), <ahref="#commitData">commitData</a>(), and <ahref="session.html">the Session Management overview</a>.
<p> Returns the current <ahref="session.html">session's</a> identifier.
<p> If the application has been restored from an earlier session, this
identifier is the same as it was in that previous session.
<p> The session identifier is guaranteed to be unique both for different
applications and for different instances of the same application.
<p><p>See also <ahref="#isSessionRestored">isSessionRestored</a>(), <ahref="#sessionKey">sessionKey</a>(), <ahref="#commitData">commitData</a>(), and <ahref="#saveState">saveState</a>().
<p> Returns the session key in the current <ahref="session.html">session</a>.
<p> If the application has been restored from an earlier session, this
key is the same as it was when the previous session ended.
<p> The session key changes with every call of <ahref="#commitData">commitData</a>() or
<ahref="#saveState">saveState</a>().
<p><p>See also <ahref="#isSessionRestored">isSessionRestored</a>(), <ahref="#sessionId">sessionId</a>(), <ahref="#commitData">commitData</a>(), and <ahref="#saveState">saveState</a>().
<p><ahref="qcolor.html">QColor</a> provides more functionality for controlling color allocation and
freeing up certain colors. See <ahref="qcolor.html#enterAllocContext">QColor::enterAllocContext</a>() for more
information.
<p> To check what mode you end up with, call <ahref="qcolor.html#numBitPlanes">QColor::numBitPlanes</a>() once
the QApplication object exists. A value greater than 8 (typically
16, 24 or 32) means true color.
<p><sup>*</sup> The color cube used by Qt has 216 colors whose red,
green, and blue components always have one of the following values:
0x00, 0x33, 0x66, 0x99, 0xCC, or 0xFF.
<p><p>See also <ahref="#colorSpec">colorSpec</a>(), <ahref="qcolor.html#numBitPlanes">QColor::numBitPlanes</a>(), and <ahref="qcolor.html#enterAllocContext">QColor::enterAllocContext</a>().
<p>Examples: <ahref="helpviewer-example.html#x1041">helpviewer/main.cpp</a>, <ahref="qaxserver-example-opengl.html#x2732">opengl/main.cpp</a>, <ahref="showimg-example.html#x1361">showimg/main.cpp</a>, <ahref="tutorial1-09.html#x2347">t9/main.cpp</a>, <ahref="qaxserver-example-tetrax.html#x2716">tetrax/tetrax.cpp</a>, <ahref="tetrix-example.html#x354">tetrix/tetrix.cpp</a>, and <ahref="themes-example.html#x348">themes/main.cpp</a>.
Enables the UI effect <em>effect</em> if <em>enable</em> is TRUE, otherwise
the effect will not be used.
<p> Note: All effects are disabled on screens running at less than
16-bit color depth.
<p><p>See also <ahref="#isEffectEnabled">isEffectEnabled</a>(), <ahref="qt.html#UIEffect-enum">Qt::UIEffect</a>, and <ahref="#setDesktopSettingsAware">setDesktopSettingsAware</a>().
<p> On application start-up, the default font depends on the window
system. It can vary depending on both the window system version and
the locale. This function lets you override the default font; but
overriding may be a bad idea because, for example, some locales need
extra-large fonts to support their special characters.
<p><p>See also <ahref="#font">font</a>(), <ahref="#fontMetrics">fontMetrics</a>(), and <ahref="qwidget.html#font-prop">QWidget::font</a>.
<p>Examples: <ahref="desktop-example.html#x1724">desktop/desktop.cpp</a>, <ahref="themes-example.html#x266">themes/metal.cpp</a>, and <ahref="themes-example.html#x323">themes/themes.cpp</a>.
Sets the list of directories to search when loading libraries to <em>paths</em>.
All existing paths will be deleted and the path list will consist of the
paths given in <em>paths</em>.
<p><p>See also <ahref="#libraryPaths">libraryPaths</a>(), <ahref="#addLibraryPath">addLibraryPath</a>(), <ahref="#removeLibraryPath">removeLibraryPath</a>(), and <ahref="qlibrary.html">QLibrary</a>.
<p><p>See also <ahref="#overrideCursor">overrideCursor</a>(), <ahref="#restoreOverrideCursor">restoreOverrideCursor</a>(), and <ahref="qwidget.html#cursor-prop">QWidget::cursor</a>.
<p>Examples: <ahref="distributor-example.html#x2653">distributor/distributor.ui.h</a>, <ahref="archivesearch-example.html#x474">network/archivesearch/archivedialog.ui.h</a>, <ahref="ftpclient-example.html#x738">network/ftpclient/ftpmainwindow.ui.h</a>, and <ahref="showimg-example.html#x1312">showimg/showimg.cpp</a>.
Changes the default application palette to <em>palette</em>. If <em>informWidgets</em> is TRUE, then existing widgets are informed about the
change and may adjust themselves to the new application
setting. If <em>informWidgets</em> is FALSE, the change only affects newly
created widgets.
<p> If <em>className</em> is passed, the change applies only to widgets that
inherit <em>className</em> (as reported by <ahref="qobject.html#inherits">QObject::inherits</a>()). If
<em>className</em> is left 0, the change affects all widgets, thus overriding
any previously set class specific palettes.
<p> The palette may be changed according to the current GUI style in
<ahref="qstyle.html#polish">QStyle::polish</a>().
<p><p>See also <ahref="qwidget.html#palette-prop">QWidget::palette</a>, <ahref="#palette">palette</a>(), and <ahref="qstyle.html#polish">QStyle::polish</a>().
<p>Examples: <ahref="i18n-example.html#x1934">i18n/main.cpp</a>, <ahref="themes-example.html#x267">themes/metal.cpp</a>, <ahref="themes-example.html#x324">themes/themes.cpp</a>, and <ahref="themes-example.html#x187">themes/wood.cpp</a>.
Sets the application's GUI style to <em>style</em>. Ownership of the style
object is transferred to QApplication, so QApplication will delete
the style object on application exit or when a new style is set.
<p> Example usage:
<pre>
QApplication::<ahref="#setStyle">setStyle</a>( new <ahref="qwindowsstyle.html">QWindowsStyle</a> );
</pre>
<p> When switching application styles, the color palette is set back to
the initial colors or the system defaults. This is necessary since
certain styles have to adapt the color palette to be fully
style-guide compliant.
<p><p>See also <ahref="#style">style</a>(), <ahref="qstyle.html">QStyle</a>, <ahref="#setPalette">setPalette</a>(), and <ahref="#desktopSettingsAware">desktopSettingsAware</a>().
<p> Qt uses this value internally, e.g. in <ahref="qfiledialog.html">QFileDialog</a>.
<p> The default value is 4 pixels.
<p><p>See also <ahref="#setStartDragDistance">setStartDragDistance</a>(), <ahref="#startDragTime">startDragTime</a>(), and <ahref="qpoint.html#manhattanLength">QPoint::manhattanLength</a>().
QWidgetListIt it( *list ); // iterate over the widgets
<ahref="qwidget.html">QWidget</a> * w;
while ( (w=it.current()) != 0 ) { // for each top level widget...
++it;
if ( !w-><ahref="qwidget.html#isVisible">isVisible</a>() )
w-><ahref="qwidget.html#show">show</a>();
}
delete list; // delete the list, not the widgets
</pre>
<p><b>Warning:</b> Delete the list as soon you have finished using it.
The widgets in the list may be deleted by someone else at any time.
<p><p>See also <ahref="#allWidgets">allWidgets</a>(), <ahref="qwidget.html#isTopLevel-prop">QWidget::isTopLevel</a>, <ahref="qwidget.html#visible-prop">QWidget::visible</a>, and <ahref="qptrlist.html#isEmpty">QPtrList::isEmpty</a>().
</h3><p><b>Note:</b> This function is <ahref="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
Returns the translation text for <em>sourceText</em>, by querying the
installed messages files. The message files are searched from the most
recently installed message file back to the first installed message
file.
<p><ahref="qobject.html#tr">QObject::tr</a>() and <ahref="qobject.html#trUtf8">QObject::trUtf8</a>() provide this functionality more
conveniently.
<p><em>context</em> is typically a class name (e.g., "MyDialog") and
<em>sourceText</em> is either English text or a short identifying text, if
the output text will be very long (as for help texts).
<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
default, it is null. <em>encoding</em> indicates the 8-bit encoding of
character stings
<p> See the <ahref="qtranslator.html">QTranslator</a> documentation for more information about
contexts and comments.
<p> If none of the message files contain a translation for <em>sourceText</em> in <em>context</em>, this function returns a <ahref="qstring.html">QString</a>
equivalent of <em>sourceText</em>. The encoding of <em>sourceText</em> is
specified by <em>encoding</em>; it defaults to <ahref="#Encoding-enum">DefaultCodec</a>.
<p> This function is not virtual. You can use alternative translation
techniques by subclassing <ahref="qtranslator.html">QTranslator</a>.
<p><b>Warning:</b> This method is reentrant only if all translators are
installed <em>before</em> calling this method. Installing or removing
translators while performing translations is not supported. Doing
so will most likely result in crashes or other undesirable behavior.
<p><p>See also <ahref="qobject.html#tr">QObject::tr</a>(), <ahref="#installTranslator">installTranslator</a>(), and <ahref="#defaultCodec">defaultCodec</a>().
Returns a pointer to the widget at global screen position <em>(x, y)</em>, or 0 if there is no Qt widget there.
<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>
is TRUE the child widget at position <em>(x, y)</em> is returned.
<p> This function is normally rather slow.
<p><p>See also <ahref="qcursor.html#pos">QCursor::pos</a>(), <ahref="qwidget.html#grabMouse">QWidget::grabMouse</a>(), and <ahref="qwidget.html#grabKeyboard">QWidget::grabKeyboard</a>().
to crashes on certain platforms due to the platforms printf implementation.
<p><p>See also <ahref="#qWarning">qWarning</a>(), <ahref="#qFatal">qFatal</a>(), <ahref="#qInstallMsgHandler">qInstallMsgHandler</a>(), and <ahref="debug.html">Debugging</a>.
to crashes on certain platforms due to the platforms printf implementation.
<p><p>See also <ahref="#qDebug">qDebug</a>(), <ahref="#qWarning">qWarning</a>(), <ahref="#qInstallMsgHandler">qInstallMsgHandler</a>(), and <ahref="debug.html">Debugging</a>.
to crashes on certain platforms due to the platforms printf implementation.
<p><p>See also <ahref="#qDebug">qDebug</a>(), <ahref="#qFatal">qFatal</a>(), <ahref="#qInstallMsgHandler">qInstallMsgHandler</a>(), and <ahref="debug.html">Debugging</a>.
<!-- eof -->
<hr><p>
This file is part of the <ahref="index.html">Qt toolkit</a>.