Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 328

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qcoreapplication.cpp -->
  <title>QCoreApplication Class | Qt Core 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QCoreApplication</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#reimplemented-protected-functions">Reimplemented Protected Functions</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#macros">Macros</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#the-event-loop-and-event-handling">The Event Loop and Event Handling</a></li>
<li class="level2"><a href="#application-and-library-paths">Application and Library Paths</a></li>
<li class="level2"><a href="#internationalization-and-translations">Internationalization and Translations</a></li>
<li class="level2"><a href="#accessing-command-line-arguments">Accessing Command Line Arguments</a></li>
<li class="level2"><a href="#locale-settings">Locale Settings</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QCoreApplication Class</h1>
<!-- $$$QCoreApplication-brief -->
<p>The <a href="qcoreapplication.html">QCoreApplication</a> class provides an event loop for Qt applications without UI. <a href="#details">More...</a></p>
<!-- @@@QCoreApplication -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QCoreApplication&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qobject.html">QObject</a></td></tr></table></div><ul>
<li><a href="qcoreapplication-members.html">List of all members, including inherited members</a></li>
<li><a href="qcoreapplication-obsolete.html">Obsolete members</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<div class="table"><table class="propsummary">
<tr><td class="topAlign"><ul>
<li class="fn"><b><a href="qcoreapplication.html#applicationName-prop">applicationName</a></b> : QString</li>
<li class="fn"><b><a href="qcoreapplication.html#applicationVersion-prop">applicationVersion</a></b> : QString</li>
<li class="fn"><b><a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a></b> : QString</li>
</ul></td><td class="topAlign"><ul>
<li class="fn"><b><a href="qcoreapplication.html#organizationName-prop">organizationName</a></b> : QString</li>
<li class="fn"><b><a href="qcoreapplication.html#quitLockEnabled-prop">quitLockEnabled</a></b> : bool</li>
</ul>
</td></tr>
</table></div>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#QCoreApplication">QCoreApplication</a></b>(int &amp;<i>argc</i>, char **<i>argv</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#dtor.QCoreApplication">~QCoreApplication</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#installNativeEventFilter">installNativeEventFilter</a></b>(QAbstractNativeEventFilter *<i>filterObj</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#notify">notify</a></b>(QObject *<i>receiver</i>, QEvent *<i>event</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#removeNativeEventFilter">removeNativeEventFilter</a></b>(QAbstractNativeEventFilter *<i>filterObject</i>)</td></tr>
</table></div>
<ul>
<li class="fn">32 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h2 id="public-slots">Public Slots</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#quit">quit</a></b>()</td></tr>
</table></div>
<ul>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#aboutToQuit">aboutToQuit</a></b>()</td></tr>
</table></div>
<ul>
<li class="fn">2 signals inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a></b>(const QString &amp;<i>path</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#applicationDirPath">applicationDirPath</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#applicationName-prop">applicationName</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#applicationPid">applicationPid</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#applicationVersion-prop">applicationVersion</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#arguments">arguments</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#closingDown">closingDown</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAbstractEventDispatcher *</td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#eventDispatcher">eventDispatcher</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#exec">exec</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#exit">exit</a></b>(int <i>returnCode</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#installTranslator">installTranslator</a></b>(QTranslator *<i>translationFile</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QCoreApplication *</td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#instance">instance</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#quitLockEnabled-prop">isQuitLockEnabled</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#isSetuidAllowed">isSetuidAllowed</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#libraryPaths">libraryPaths</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#organizationName-prop">organizationName</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#postEvent">postEvent</a></b>(QObject *<i>receiver</i>, QEvent *<i>event</i>, int <i>priority</i> = Qt::NormalEventPriority)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#processEvents">processEvents</a></b>(QEventLoop::ProcessEventsFlags <i>flags</i> = QEventLoop::AllEvents)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#processEvents-1">processEvents</a></b>(QEventLoop::ProcessEventsFlags <i>flags</i>, int <i>maxtime</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a></b>(const QString &amp;<i>path</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#removePostedEvents">removePostedEvents</a></b>(QObject *<i>receiver</i>, int <i>eventType</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#removeTranslator">removeTranslator</a></b>(QTranslator *<i>translationFile</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#sendEvent">sendEvent</a></b>(QObject *<i>receiver</i>, QEvent *<i>event</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a></b>(QObject *<i>receiver</i> = Q_NULLPTR, int <i>event_type</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#applicationName-prop">setApplicationName</a></b>(const QString &amp;<i>application</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#applicationVersion-prop">setApplicationVersion</a></b>(const QString &amp;<i>version</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#setAttribute">setAttribute</a></b>(Qt::ApplicationAttribute <i>attribute</i>, bool <i>on</i> = true)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#setEventDispatcher">setEventDispatcher</a></b>(QAbstractEventDispatcher *<i>eventDispatcher</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a></b>(const QStringList &amp;<i>paths</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#organizationDomain-prop">setOrganizationDomain</a></b>(const QString &amp;<i>orgDomain</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#organizationName-prop">setOrganizationName</a></b>(const QString &amp;<i>orgName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#quitLockEnabled-prop">setQuitLockEnabled</a></b>(bool <i>enabled</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#setSetuidAllowed">setSetuidAllowed</a></b>(bool <i>allow</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#startingUp">startingUp</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#testAttribute">testAttribute</a></b>(Qt::ApplicationAttribute <i>attribute</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#translate">translate</a></b>(const char *<i>context</i>, const char *<i>sourceText</i>, const char *<i>disambiguation</i> = Q_NULLPTR, int <i>n</i> = -1)</td></tr>
</table></div>
<ul>
<li class="fn">11 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="reimplemented-protected-functions"></a>
<h2 id="reimplemented-protected-functions">Reimplemented Protected Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#event">event</a></b>(QEvent *<i>e</i>)</td></tr>
</table></div>
<ul>
<li class="fn">9 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#qAddPostRoutine">qAddPostRoutine</a></b>(QtCleanUpFunction <i>ptr</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#qRemovePostRoutine">qRemovePostRoutine</a></b>(QtCleanUpFunction <i>ptr</i>)</td></tr>
</table></div>
<a name="macros"></a>
<h2 id="macros">Macros</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#Q_COREAPP_STARTUP_FUNCTION">Q_COREAPP_STARTUP_FUNCTION</a></b>(QtStartUpFunction <i>ptr</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcoreapplication.html#Q_DECLARE_TR_FUNCTIONS">Q_DECLARE_TR_FUNCTIONS</a></b>(<i>context</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QCoreApplication-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qcoreapplication.html">QCoreApplication</a> class provides an event loop for Qt applications without UI.</p>
<p>This class is used by non-GUI applications to provide their event loop. For non-GUI application that uses Qt, there should be exactly one <a href="qcoreapplication.html">QCoreApplication</a> object. For GUI applications, see <a href="../qtgui/qguiapplication.html">QGuiApplication</a>. For applications that use the Qt Widgets module, see <a href="../qtwidgets/qapplication.html">QApplication</a>.</p>
<p><a href="qcoreapplication.html">QCoreApplication</a> contains the main event loop, where all events from the operating system (e.g&#x2e;, timer and network events) and other sources are processed and dispatched. It also handles the application's initialization and finalization, as well as system-wide and application-wide settings.</p>
<a name="the-event-loop-and-event-handling"></a>
<h3 >The Event Loop and Event Handling</h3>
<p>The event loop is started with a call to <a href="qcoreapplication.html#exec">exec</a>(). Long-running operations can call <a href="qcoreapplication.html#processEvents">processEvents</a>() to keep the application responsive.</p>
<p>In general, we recommend that you create a <a href="qcoreapplication.html">QCoreApplication</a>, <a href="../qtgui/qguiapplication.html">QGuiApplication</a> or a <a href="../qtwidgets/qapplication.html">QApplication</a> object in your <code>main()</code> function as early as possible. <a href="qcoreapplication.html#exec">exec</a>() will not return until the event loop exits; e.g&#x2e;, when <a href="qcoreapplication.html#quit">quit</a>() is called.</p>
<p>Several static convenience functions are also provided. The <a href="qcoreapplication.html">QCoreApplication</a> object is available from <a href="qcoreapplication.html#instance">instance</a>(). Events can be sent with <a href="qcoreapplication.html#sendEvent">sendEvent</a>() or posted to an event queue with <a href="qcoreapplication.html#postEvent">postEvent</a>(). Pending events can be removed with <a href="qcoreapplication.html#removePostedEvents">removePostedEvents</a>() or dispatched with <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>().</p>
<p>The class provides a <a href="qcoreapplication.html#quit">quit</a>() slot and an <a href="qcoreapplication.html#aboutToQuit">aboutToQuit</a>() signal.</p>
<a name="application-and-library-paths"></a>
<h3 >Application and Library Paths</h3>
<p>An application has an <a href="qcoreapplication.html#applicationDirPath">applicationDirPath</a>() and an <a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a>(). Library paths (see <a href="qlibrary.html">QLibrary</a>) can be retrieved with <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>() and manipulated by <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>(), <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), and <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>().</p>
<a name="internationalization-and-translations"></a>
<h3 >Internationalization and Translations</h3>
<p>Translation files can be added or removed using <a href="qcoreapplication.html#installTranslator">installTranslator</a>() and <a href="qcoreapplication.html#removeTranslator">removeTranslator</a>(). Application strings can be translated using <a href="qcoreapplication.html#translate">translate</a>(). The <a href="qobject.html#tr">QObject::tr</a>() and QObject::trUtf8() functions are implemented in terms of <a href="qcoreapplication.html#translate">translate</a>().</p>
<a name="accessing-command-line-arguments"></a>
<h3 >Accessing Command Line Arguments</h3>
<p>The command line arguments which are passed to <a href="qcoreapplication.html">QCoreApplication</a>'s constructor should be accessed using the <a href="qcoreapplication.html#arguments">arguments</a>() function.</p>
<p><b>Note: </b><a href="qcoreapplication.html">QCoreApplication</a> removes option <code>-qmljsdebugger=&quot;..&#x2e;&quot;</code>. It parses the argument of <code>qmljsdebugger</code>, and then removes this option plus its argument.</p><p>For more advanced command line option handling, create a <a href="qcommandlineparser.html">QCommandLineParser</a>.</p>
<a name="locale-settings"></a>
<h3 >Locale Settings</h3>
<p>On Unix/Linux Qt is configured to use the system locale settings by default. This can cause a conflict when using POSIX functions, for instance, when converting between data types such as floats and strings, since the notation may differ between locales. To get around this problem, call the POSIX function <code>setlocale(LC_NUMERIC,&quot;C&quot;)</code> right after initializing <a href="../qtwidgets/qapplication.html">QApplication</a>, <a href="../qtgui/qguiapplication.html">QGuiApplication</a> or <a href="qcoreapplication.html">QCoreApplication</a> to reset the locale that is used for number formatting to &quot;C&quot;-locale.</p>
</div>
<p><b>See also </b><a href="../qtgui/qguiapplication.html">QGuiApplication</a>, <a href="qabstracteventdispatcher.html">QAbstractEventDispatcher</a>, <a href="qeventloop.html">QEventLoop</a>, <a href="qtcore-threads-semaphores-example.html">Semaphores Example</a>, and <a href="qtcore-threads-waitconditions-example.html">Wait Conditions Example</a>.</p>
<!-- @@@QCoreApplication -->
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$applicationName-prop$$$applicationName$$$setApplicationNameconstQString& -->
<h3 class="fn" id="applicationName-prop"><a name="applicationName-prop"></a><span class="name">applicationName</span> : <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the name of this application</p>
<p>The value is used by the <a href="qsettings.html">QSettings</a> class when it is constructed using the empty constructor. This saves having to repeat this information each time a <a href="qsettings.html">QSettings</a> object is created.</p>
<p>If not set, the application name defaults to the executable name (since 5.0).</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>applicationName</b></span>()</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setApplicationName</b></span>(const QString &amp;<i>application</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qcoreapplication.html#organizationName-prop">organizationName</a>, <a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a>, <a href="qcoreapplication.html#applicationVersion-prop">applicationVersion</a>, and <a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a>().</p>
<!-- @@@applicationName -->
<!-- $$$applicationVersion-prop$$$applicationVersion$$$setApplicationVersionconstQString& -->
<h3 class="fn" id="applicationVersion-prop"><a name="applicationVersion-prop"></a><span class="name">applicationVersion</span> : <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the version of this application</p>
<p>If not set, the application version defaults to a platform-specific value determined from the main application executable or package (since Qt 5.9):</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Platform</th><th >Source</th></tr></thead>
<tr valign="top" class="odd"><td >Windows (classic desktop)</td><td >PRODUCTVERSION parameter of the VERSIONINFO resource</td></tr>
<tr valign="top" class="even"><td >Universal Windows Platform</td><td >version attribute of the application package manifest</td></tr>
<tr valign="top" class="odd"><td >macOS, iOS, tvOS, watchOS</td><td >CFBundleVersion property of the information property list</td></tr>
<tr valign="top" class="even"><td >Android</td><td >android:versionName property of the AndroidManifest.xml manifest element</td></tr>
</table></div>
<p>On other platforms, the default is the empty string.</p>
<p>This property was introduced in  Qt 4.4.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>applicationVersion</b></span>()</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setApplicationVersion</b></span>(const QString &amp;<i>version</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qcoreapplication.html#applicationName-prop">applicationName</a>, <a href="qcoreapplication.html#organizationName-prop">organizationName</a>, and <a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a>.</p>
<!-- @@@applicationVersion -->
<!-- $$$organizationDomain-prop$$$organizationDomain$$$setOrganizationDomainconstQString& -->
<h3 class="fn" id="organizationDomain-prop"><a name="organizationDomain-prop"></a><span class="name">organizationDomain</span> : <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the Internet domain of the organization that wrote this application</p>
<p>The value is used by the <a href="qsettings.html">QSettings</a> class when it is constructed using the empty constructor. This saves having to repeat this information each time a <a href="qsettings.html">QSettings</a> object is created.</p>
<p>On Mac, <a href="qsettings.html">QSettings</a> uses organizationDomain() as the organization if it's not an empty string; otherwise it uses <a href="qcoreapplication.html#organizationName-prop">organizationName</a>(). On all other platforms, <a href="qsettings.html">QSettings</a> uses <a href="qcoreapplication.html#organizationName-prop">organizationName</a>() as the organization.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>organizationDomain</b></span>()</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setOrganizationDomain</b></span>(const QString &amp;<i>orgDomain</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qcoreapplication.html#organizationName-prop">organizationName</a>, <a href="qcoreapplication.html#applicationName-prop">applicationName</a>, and <a href="qcoreapplication.html#applicationVersion-prop">applicationVersion</a>.</p>
<!-- @@@organizationDomain -->
<!-- $$$organizationName-prop$$$organizationName$$$setOrganizationNameconstQString& -->
<h3 class="fn" id="organizationName-prop"><a name="organizationName-prop"></a><span class="name">organizationName</span> : <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the name of the organization that wrote this application</p>
<p>The value is used by the <a href="qsettings.html">QSettings</a> class when it is constructed using the empty constructor. This saves having to repeat this information each time a <a href="qsettings.html">QSettings</a> object is created.</p>
<p>On Mac, <a href="qsettings.html">QSettings</a> uses <a href="qcoreapplication.html#organizationDomain-prop">organizationDomain()</a> as the organization if it's not an empty string; otherwise it uses organizationName(). On all other platforms, <a href="qsettings.html">QSettings</a> uses organizationName() as the organization.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>organizationName</b></span>()</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setOrganizationName</b></span>(const QString &amp;<i>orgName</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a> and <a href="qcoreapplication.html#applicationName-prop">applicationName</a>.</p>
<!-- @@@organizationName -->
<!-- $$$quitLockEnabled-prop$$$isQuitLockEnabled$$$setQuitLockEnabledbool -->
<h3 class="fn" id="quitLockEnabled-prop"><a name="quitLockEnabled-prop"></a><span class="name">quitLockEnabled</span> : <span class="type">bool</span></h3>
<p>This property holds whether the use of the <a href="qeventlooplocker.html">QEventLoopLocker</a> feature can cause the application to quit.</p>
<p>The default is <code>true</code>.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>isQuitLockEnabled</b></span>()</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setQuitLockEnabled</b></span>(bool <i>enabled</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qeventlooplocker.html">QEventLoopLocker</a>.</p>
<!-- @@@quitLockEnabled -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QCoreApplication[overload1]$$$QCoreApplicationint&char** -->
<h3 class="fn" id="QCoreApplication"><a name="QCoreApplication"></a>QCoreApplication::<span class="name">QCoreApplication</span>(<span class="type">int</span> &amp;<i>argc</i>, <span class="type">char</span> **<i>argv</i>)</h3>
<p>Constructs a Qt core application. Core applications are applications without a graphical user interface. Such applications are used at the console or as server processes.</p>
<p>The <i>argc</i> and <i>argv</i> arguments are processed by the application, and made available in a more convenient form by the <a href="qcoreapplication.html#arguments">arguments</a>() function.</p>
<p><b>Warning:</b> The data referred to by <i>argc</i> and <i>argv</i> must stay valid for the entire lifetime of the <a href="qcoreapplication.html">QCoreApplication</a> object. In addition, <i>argc</i> must be greater than zero and <i>argv</i> must contain at least one valid character string.</p>
<!-- @@@QCoreApplication -->
<!-- $$$~QCoreApplication[overload1]$$$~QCoreApplication -->
<h3 class="fn" id="dtor.QCoreApplication"><a name="dtor.QCoreApplication"></a>QCoreApplication::<span class="name">~QCoreApplication</span>()</h3>
<p>Destroys the <a href="qcoreapplication.html">QCoreApplication</a> object.</p>
<!-- @@@~QCoreApplication -->
<!-- $$$aboutToQuit[overload1]$$$aboutToQuit -->
<h3 class="fn" id="aboutToQuit"><a name="aboutToQuit"></a><code>[signal] </code><span class="type">void</span> QCoreApplication::<span class="name">aboutToQuit</span>()</h3>
<p>This signal is emitted when the application is about to quit the main event loop, e.g&#x2e; when the event loop level drops to zero. This may happen either after a call to <a href="qcoreapplication.html#quit">quit</a>() from inside the application or when the user shuts down the entire desktop session.</p>
<p>The signal is particularly useful if your application has to do some last-second cleanup. Note that no user interaction is possible in this state.</p>
<p><b>Note: </b>This is a private signal. It can be used in signal connections but cannot be emitted by the user.</p>
<p><b>See also </b><a href="qcoreapplication.html#quit">quit</a>().</p>
<!-- @@@aboutToQuit -->
<!-- $$$addLibraryPath[overload1]$$$addLibraryPathconstQString& -->
<h3 class="fn" id="addLibraryPath"><a name="addLibraryPath"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">addLibraryPath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i>)</h3>
<p>Prepends <i>path</i> to the beginning of the library path list, ensuring that it is searched for libraries first. If <i>path</i> is empty or already in the path list, the path list is not changed.</p>
<p>The default path list consists of a single entry, the installation directory for plugins. The default installation directory for plugins is <code>INSTALL/plugins</code>, where <code>INSTALL</code> is the directory where Qt was installed.</p>
<p>The library paths are reset to the default when an instance of <a href="qcoreapplication.html">QCoreApplication</a> is destructed.</p>
<p><b>See also </b><a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>(), <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>(), and <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>().</p>
<!-- @@@addLibraryPath -->
<!-- $$$applicationDirPath[overload1]$$$applicationDirPath -->
<h3 class="fn" id="applicationDirPath"><a name="applicationDirPath"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QCoreApplication::<span class="name">applicationDirPath</span>()</h3>
<p>Returns the directory that contains the application executable.</p>
<p>For example, if you have installed Qt in the <code>C:\Qt</code> directory, and you run the <code>regexp</code> example, this function will return &quot;C:/Qt/examples/tools/regexp&quot;.</p>
<p>On macOS and iOS this will point to the directory actually containing the executable, which may be inside an application bundle (if the application is bundled).</p>
<p><b>Warning:</b> On Linux, this function will try to get the path from the <code>/proc</code> file system. If that fails, it assumes that <code>argv[0]</code> contains the absolute file name of the executable. The function also assumes that the current directory has not been changed by the application.</p>
<p><b>See also </b><a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a>().</p>
<!-- @@@applicationDirPath -->
<!-- $$$applicationFilePath[overload1]$$$applicationFilePath -->
<h3 class="fn" id="applicationFilePath"><a name="applicationFilePath"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QCoreApplication::<span class="name">applicationFilePath</span>()</h3>
<p>Returns the file path of the application executable.</p>
<p>For example, if you have installed Qt in the <code>/usr/local/qt</code> directory, and you run the <code>regexp</code> example, this function will return &quot;/usr/local/qt/examples/tools/regexp/regexp&quot;.</p>
<p><b>Warning:</b> On Linux, this function will try to get the path from the <code>/proc</code> file system. If that fails, it assumes that <code>argv[0]</code> contains the absolute file name of the executable. The function also assumes that the current directory has not been changed by the application.</p>
<p><b>See also </b><a href="qcoreapplication.html#applicationDirPath">applicationDirPath</a>().</p>
<!-- @@@applicationFilePath -->
<!-- $$$applicationPid[overload1]$$$applicationPid -->
<h3 class="fn" id="applicationPid"><a name="applicationPid"></a><code>[static] </code><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QCoreApplication::<span class="name">applicationPid</span>()</h3>
<p>Returns the current process ID for the application.</p>
<p>This function was introduced in  Qt 4.4.</p>
<!-- @@@applicationPid -->
<!-- $$$arguments[overload1]$$$arguments -->
<h3 class="fn" id="arguments"><a name="arguments"></a><code>[static] </code><span class="type"><a href="qstringlist.html">QStringList</a></span> QCoreApplication::<span class="name">arguments</span>()</h3>
<p>Returns the list of command-line arguments.</p>
<p>Usually arguments().at(0) is the program name, arguments().at(1) is the first argument, and arguments().last() is the last argument. See the note below about Windows.</p>
<p>Calling this function is slow - you should store the result in a variable when parsing the command line.</p>
<p><b>Warning:</b> On Unix, this list is built from the argc and argv parameters passed to the constructor in the main() function. The string-data in argv is interpreted using <a href="qstring.html#fromLocal8Bit">QString::fromLocal8Bit</a>(); hence it is not possible to pass, for example, Japanese command line arguments on a system that runs in a Latin1 locale. Most modern Unix systems do not have this limitation, as they are Unicode-based.</p>
<p>On Windows, the list is built from the argc and argv parameters only if modified argv/argc parameters are passed to the constructor. In that case, encoding problems might occur.</p>
<p>Otherwise, the arguments() are constructed from the return value of <a href="http://msdn2.microsoft.com/en-us/library/ms683156(VS.85).aspx">GetCommandLine()</a>. As a result of this, the string given by arguments().at(0) might not be the program name on Windows, depending on how the application was started.</p>
<p>This function was introduced in  Qt 4.1.</p>
<p><b>See also </b><a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a>() and <a href="qcommandlineparser.html">QCommandLineParser</a>.</p>
<!-- @@@arguments -->
<!-- $$$closingDown[overload1]$$$closingDown -->
<h3 class="fn" id="closingDown"><a name="closingDown"></a><code>[static] </code><span class="type">bool</span> QCoreApplication::<span class="name">closingDown</span>()</h3>
<p>Returns <code>true</code> if the application objects are being destroyed; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qcoreapplication.html#startingUp">startingUp</a>().</p>
<!-- @@@closingDown -->
<!-- $$$event[overload1]$$$eventQEvent* -->
<h3 class="fn" id="event"><a name="event"></a><code>[virtual protected] </code><span class="type">bool</span> QCoreApplication::<span class="name">event</span>(<span class="type"><a href="qevent.html">QEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="qobject.html#event">QObject::event</a>().</p>
<!-- @@@event -->
<!-- $$$eventDispatcher[overload1]$$$eventDispatcher -->
<h3 class="fn" id="eventDispatcher"><a name="eventDispatcher"></a><code>[static] </code><span class="type"><a href="qabstracteventdispatcher.html">QAbstractEventDispatcher</a></span> *QCoreApplication::<span class="name">eventDispatcher</span>()</h3>
<p>Returns a pointer to the event dispatcher object for the main thread. If no event dispatcher exists for the thread, this function returns 0.</p>
<p><b>See also </b><a href="qcoreapplication.html#setEventDispatcher">setEventDispatcher</a>().</p>
<!-- @@@eventDispatcher -->
<!-- $$$exec[overload1]$$$exec -->
<h3 class="fn" id="exec"><a name="exec"></a><code>[static] </code><span class="type">int</span> QCoreApplication::<span class="name">exec</span>()</h3>
<p>Enters the main event loop and waits until <a href="qcoreapplication.html#exit">exit</a>() is called. Returns the value that was passed to <a href="qcoreapplication.html#exit">exit</a>() (which is 0 if <a href="qcoreapplication.html#exit">exit</a>() is called via <a href="qcoreapplication.html#quit">quit</a>()).</p>
<p>It is necessary to call this function to start event handling. The main event loop receives events from the window system and dispatches these to the application widgets.</p>
<p>To make your application perform idle processing (by executing a special function whenever there are no pending events), use a <a href="qtimer.html">QTimer</a> with 0 timeout. More advanced idle processing schemes can be achieved using <a href="qcoreapplication.html#processEvents">processEvents</a>().</p>
<p>We recommend that you connect clean-up code to the <a href="qcoreapplication.html#aboutToQuit">aboutToQuit()</a> signal, instead of putting it in your application's <code>main()</code> function because on some platforms the exec() call may not return. For example, on Windows when the user logs off, the system terminates the process after Qt closes all top-level windows. Hence, there is no guarantee that the application will have time to exit its event loop and execute code at the end of the <code>main()</code> function after the exec() call.</p>
<p><b>See also </b><a href="qcoreapplication.html#quit">quit</a>(), <a href="qcoreapplication.html#exit">exit</a>(), <a href="qcoreapplication.html#processEvents">processEvents</a>(), and <a href="../qtwidgets/qapplication.html#exec">QApplication::exec</a>().</p>
<!-- @@@exec -->
<!-- $$$exit[overload1]$$$exitint -->
<h3 class="fn" id="exit"><a name="exit"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">exit</span>(<span class="type">int</span> <i>returnCode</i> = 0)</h3>
<p>Tells the application to exit with a return code.</p>
<p>After this function has been called, the application leaves the main event loop and returns from the call to <a href="qcoreapplication.html#exec">exec</a>(). The <a href="qcoreapplication.html#exec">exec</a>() function returns <i>returnCode</i>. If the event loop is not running, this function does nothing.</p>
<p>By convention, a <i>returnCode</i> of 0 means success, and any non-zero value indicates an error.</p>
<p>Note that unlike the C library function of the same name, this function <i>does</i> return to the caller -- it is event processing that stops.</p>
<p><b>See also </b><a href="qcoreapplication.html#quit">quit</a>() and <a href="qcoreapplication.html#exec">exec</a>().</p>
<!-- @@@exit -->
<!-- $$$installNativeEventFilter[overload1]$$$installNativeEventFilterQAbstractNativeEventFilter* -->
<h3 class="fn" id="installNativeEventFilter"><a name="installNativeEventFilter"></a><span class="type">void</span> QCoreApplication::<span class="name">installNativeEventFilter</span>(<span class="type"><a href="qabstractnativeeventfilter.html">QAbstractNativeEventFilter</a></span> *<i>filterObj</i>)</h3>
<p>Installs an event filter <i>filterObj</i> for all native events received by the application in the main thread.</p>
<p>The event filter <i>filterObj</i> receives events via its <a href="qabstractnativeeventfilter.html#nativeEventFilter">nativeEventFilter()</a> function, which is called for all native events received in the main thread.</p>
<p>The <a href="qabstractnativeeventfilter.html#nativeEventFilter">QAbstractNativeEventFilter::nativeEventFilter</a>() function should return true if the event should be filtered, i.e&#x2e; stopped. It should return false to allow normal Qt processing to continue: the native event can then be translated into a <a href="qevent.html">QEvent</a> and handled by the standard Qt <a href="qevent.html">event</a> filtering, e.g&#x2e; <a href="qobject.html#installEventFilter">QObject::installEventFilter</a>().</p>
<p>If multiple event filters are installed, the filter that was installed last is activated first.</p>
<p><b>Note: </b>The filter function set here receives native messages, i.e&#x2e; MSG or XCB event structs.</p><p><b>Note: </b>Native event filters will be disabled in the application when the <a href="qt.html#ApplicationAttribute-enum">Qt::AA_PluginApplication</a> attribute is set.</p><p>For maximum portability, you should always try to use <a href="qevent.html">QEvent</a> and <a href="qobject.html#installEventFilter">QObject::installEventFilter</a>() whenever possible.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qobject.html#installEventFilter">QObject::installEventFilter</a>().</p>
<!-- @@@installNativeEventFilter -->
<!-- $$$installTranslator[overload1]$$$installTranslatorQTranslator* -->
<h3 class="fn" id="installTranslator"><a name="installTranslator"></a><code>[static] </code><span class="type">bool</span> QCoreApplication::<span class="name">installTranslator</span>(<span class="type"><a href="qtranslator.html">QTranslator</a></span> *<i>translationFile</i>)</h3>
<p>Adds the translation file <i>translationFile</i> to the list of translation files to be used for translations.</p>
<p>Multiple translation files can be installed. Translations are searched for in the reverse order in which they were installed, so the most recently installed translation file is searched first and the first translation file installed is searched last. The search stops as soon as a translation containing a matching string is found.</p>
<p>Installing or removing a <a href="qtranslator.html">QTranslator</a>, or changing an installed <a href="qtranslator.html">QTranslator</a> generates a <a href="qevent.html#Type-enum">LanguageChange</a> event for the <a href="qcoreapplication.html">QCoreApplication</a> instance. A <a href="../qtwidgets/qapplication.html">QApplication</a> instance will propagate the event to all toplevel widgets, where a reimplementation of changeEvent can re-translate the user interface by passing user-visible strings via the <a href="qobject.html#tr">tr</a>() function to the respective property setters. User-interface classes generated by Qt Designer provide a <code>retranslateUi()</code> function that can be called.</p>
<p>The function returns <code>true</code> on success and false on failure.</p>
<p><b>See also </b><a href="qcoreapplication.html#removeTranslator">removeTranslator</a>(), <a href="qcoreapplication.html#translate">translate</a>(), <a href="qtranslator.html#load">QTranslator::load</a>(), and Dynamic Translation.</p>
<!-- @@@installTranslator -->
<!-- $$$instance[overload1]$$$instance -->
<h3 class="fn" id="instance"><a name="instance"></a><code>[static] </code><span class="type"><a href="qcoreapplication.html#QCoreApplication">QCoreApplication</a></span> *QCoreApplication::<span class="name">instance</span>()</h3>
<p>Returns a pointer to the application's <a href="qcoreapplication.html">QCoreApplication</a> (or <a href="../qtgui/qguiapplication.html">QGuiApplication</a>/<a href="../qtwidgets/qapplication.html">QApplication</a>) instance.</p>
<p>If no instance has been allocated, <code>null</code> is returned.</p>
<!-- @@@instance -->
<!-- $$$isSetuidAllowed[overload1]$$$isSetuidAllowed -->
<h3 class="fn" id="isSetuidAllowed"><a name="isSetuidAllowed"></a><code>[static] </code><span class="type">bool</span> QCoreApplication::<span class="name">isSetuidAllowed</span>()</h3>
<p>Returns true if the application is allowed to run setuid on UNIX platforms.</p>
<p>This function was introduced in  Qt 5.3.</p>
<p><b>See also </b><a href="qcoreapplication.html#setSetuidAllowed">QCoreApplication::setSetuidAllowed</a>().</p>
<!-- @@@isSetuidAllowed -->
<!-- $$$libraryPaths[overload1]$$$libraryPaths -->
<h3 class="fn" id="libraryPaths"><a name="libraryPaths"></a><code>[static] </code><span class="type"><a href="qstringlist.html">QStringList</a></span> QCoreApplication::<span class="name">libraryPaths</span>()</h3>
<p>Returns a list of paths that the application will search when dynamically loading libraries.</p>
<p>The return value of this function may change when a <a href="qcoreapplication.html">QCoreApplication</a> is created. It is not recommended to call it before creating a <a href="qcoreapplication.html">QCoreApplication</a>. The directory of the application executable (<b>not</b> the working directory) is part of the list if it is known. In order to make it known a <a href="qcoreapplication.html">QCoreApplication</a> has to be constructed as it will use <code>argv[0]</code> to find it.</p>
<p>Qt provides default library paths, but they can also be set using a qt.conf file. Paths specified in this file will override default values. Note that if the qt.conf file is in the directory of the application executable, it may not be found until a <a href="qcoreapplication.html">QCoreApplication</a> is created. If it is not found when calling this function, the default library paths will be used.</p>
<p>The list will include the installation directory for plugins if it exists (the default installation directory for plugins is <code>INSTALL/plugins</code>, where <code>INSTALL</code> is the directory where Qt was installed). The colon separated entries of the <code>QT_PLUGIN_PATH</code> environment variable are always added. The plugin installation directory (and its existence) may change when the directory of the application executable becomes known.</p>
<p>If you want to iterate over the list, you can use the <a href="containers.html#foreach">foreach</a> pseudo-keyword:</p>
<pre class="cpp">

  foreach (<span class="keyword">const</span> <span class="type"><a href="qstring.html">QString</a></span> <span class="operator">&amp;</span>path<span class="operator">,</span> app<span class="operator">.</span>libraryPaths())
      do_something(path);

</pre>
<p><b>See also </b><a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>(), <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>(), <a href="qlibrary.html">QLibrary</a>, and How to Create Qt Plugins.</p>
<!-- @@@libraryPaths -->
<!-- $$$notify[overload1]$$$notifyQObject*QEvent* -->
<h3 class="fn" id="notify"><a name="notify"></a><code>[virtual] </code><span class="type">bool</span> QCoreApplication::<span class="name">notify</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, <span class="type"><a href="qevent.html">QEvent</a></span> *<i>event</i>)</h3>
<p>Sends <i>event</i> to <i>receiver</i>: <i>receiver</i>-&gt;event(<i>event</i>). Returns the value that is returned from the receiver's event handler. Note that this function is called for all events sent to any object in any thread.</p>
<p>For certain types of events (e.g&#x2e; mouse and key events), the event will be propagated to the receiver's parent and so on up to the top-level object if the receiver is not interested in the event (i.e&#x2e;, it returns <code>false</code>).</p>
<p>There are five different ways that events can be processed; reimplementing this virtual function is just one of them. All five approaches are listed below:</p>
<ol class="1" type="1"><li>Reimplementing <a href="../qtwidgets/qwidget.html#paintEvent">paintEvent()</a>, <a href="../qtwidgets/qwidget.html#mousePressEvent">mousePressEvent()</a> and so on. This is the most common, easiest, and least powerful way.</li>
<li>Reimplementing this function. This is very powerful, providing complete control; but only one subclass can be active at a time.</li>
<li>Installing an event filter on <a href="qcoreapplication.html#instance">QCoreApplication::instance</a>(). Such an event filter is able to process all events for all widgets, so it's just as powerful as reimplementing notify(); furthermore, it's possible to have more than one application-global event filter. Global event filters even see mouse events for <a href="../qtwidgets/qwidget.html#enabled-prop">disabled widgets</a>. Note that application event filters are only called for objects that live in the main thread.</li>
<li>Reimplementing <a href="qobject.html#event">QObject::event</a>() (as <a href="../qtwidgets/qwidget.html">QWidget</a> does). If you do this you get Tab key presses, and you get to see the events before any widget-specific event filters.</li>
<li>Installing an event filter on the object. Such an event filter gets all the events, including Tab and Shift+Tab key press events, as long as they do not change the focus widget.</li>
</ol>
<p><b>Future direction:</b> This function will not be called for objects that live outside the main thread in Qt 6. Applications that need that functionality should find other solutions for their event inspection needs in the meantime. The change may be extended to the main thread, causing this function to be deprecated.</p>
<p><b>Warning:</b> If you override this function, you must ensure all threads that process events stop doing so before your application object begins destruction. This includes threads started by other libraries that you may be using, but does not apply to Qt's own threads.</p>
<p><b>See also </b><a href="qobject.html#event">QObject::event</a>() and <a href="qcoreapplication.html#installNativeEventFilter">installNativeEventFilter</a>().</p>
<!-- @@@notify -->
<!-- $$$postEvent[overload1]$$$postEventQObject*QEvent*int -->
<h3 class="fn" id="postEvent"><a name="postEvent"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">postEvent</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, <span class="type"><a href="qevent.html">QEvent</a></span> *<i>event</i>, <span class="type">int</span> <i>priority</i> = Qt::NormalEventPriority)</h3>
<p>Adds the event <i>event</i>, with the object <i>receiver</i> as the receiver of the event, to an event queue and returns immediately.</p>
<p>The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been posted. It is <i>not safe</i> to access the event after it has been posted.</p>
<p>When control returns to the main event loop, all events that are stored in the queue will be sent using the <a href="qcoreapplication.html#notify">notify</a>() function.</p>
<p>Events are sorted in descending <i>priority</i> order, i.e&#x2e; events with a high <i>priority</i> are queued before events with a lower <i>priority</i>. The <i>priority</i> can be any integer value, i.e&#x2e; between INT_MAX and INT_MIN, inclusive; see <a href="qt.html#EventPriority-enum">Qt::EventPriority</a> for more details. Events with equal <i>priority</i> will be processed in the order posted.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p>This function was introduced in  Qt 4.3.</p>
<p><b>See also </b><a href="qcoreapplication.html#sendEvent">sendEvent</a>(), <a href="qcoreapplication.html#notify">notify</a>(), <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>(), and <a href="qt.html#EventPriority-enum">Qt::EventPriority</a>.</p>
<!-- @@@postEvent -->
<!-- $$$processEvents[overload1]$$$processEventsQEventLoop::ProcessEventsFlags -->
<h3 class="fn" id="processEvents"><a name="processEvents"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">processEvents</span>(<span class="type"><a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::ProcessEventsFlags</a></span> <i>flags</i> = QEventLoop::AllEvents)</h3>
<p>Processes all pending events for the calling thread according to the specified <i>flags</i> until there are no more events to process.</p>
<p>You can call this function occasionally when your program is busy performing a long operation (e.g&#x2e; copying a file).</p>
<p>In the event that you are running a local loop which calls this function continuously, without an event loop, the <a href="qevent.html#Type-enum">DeferredDelete</a> events will not be processed. This can affect the behaviour of widgets, e.g&#x2e; <a href="../qtwidgets/qtooltip.html">QToolTip</a>, that rely on <a href="qevent.html#Type-enum">DeferredDelete</a> events to function properly. An alternative would be to call <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents()</a> from within that local loop.</p>
<p>Calling this function processes events only for the calling thread.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b><a href="qcoreapplication.html#exec">exec</a>(), <a href="qtimer.html">QTimer</a>, <a href="qeventloop.html#processEvents">QEventLoop::processEvents</a>(), <a href="qcoreapplication-obsolete.html#flush">flush</a>(), and <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>().</p>
<!-- @@@processEvents -->
<!-- $$$processEvents$$$processEventsQEventLoop::ProcessEventsFlagsint -->
<h3 class="fn" id="processEvents-1"><a name="processEvents-1"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">processEvents</span>(<span class="type"><a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::ProcessEventsFlags</a></span> <i>flags</i>, <span class="type">int</span> <i>maxtime</i>)</h3>
<p>This function overloads <a href="qcoreapplication.html#processEvents">processEvents</a>().</p>
<p>Processes pending events for the calling thread for <i>maxtime</i> milliseconds or until there are no more events to process, whichever is shorter.</p>
<p>You can call this function occasionally when your program is busy doing a long operation (e.g&#x2e; copying a file).</p>
<p>Calling this function processes events only for the calling thread.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b><a href="qcoreapplication.html#exec">exec</a>(), <a href="qtimer.html">QTimer</a>, and <a href="qeventloop.html#processEvents">QEventLoop::processEvents</a>().</p>
<!-- @@@processEvents -->
<!-- $$$quit[overload1]$$$quit -->
<h3 class="fn" id="quit"><a name="quit"></a><code>[static slot] </code><span class="type">void</span> QCoreApplication::<span class="name">quit</span>()</h3>
<p>Tells the application to exit with return code 0 (success). Equivalent to calling <a href="qcoreapplication.html#exit">QCoreApplication::exit</a>(0).</p>
<p>It's common to connect the <a href="../qtgui/qguiapplication.html#lastWindowClosed">QGuiApplication::lastWindowClosed</a>() signal to quit(), and you also often connect e.g&#x2e; <a href="../qtwidgets/qabstractbutton.html#clicked">QAbstractButton::clicked</a>() or signals in <a href="../qtwidgets/qaction.html">QAction</a>, <a href="../qtwidgets/qmenu.html">QMenu</a>, or <a href="../qtwidgets/qmenubar.html">QMenuBar</a> to it.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>quitButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span>(<span class="string">&quot;Quit&quot;</span>);
  connect(quitButton<span class="operator">,</span> SIGNAL(clicked())<span class="operator">,</span> <span class="operator">&amp;</span>app<span class="operator">,</span> SLOT(quit()));

</pre>
<p><b>See also </b><a href="qcoreapplication.html#exit">exit</a>(), <a href="qcoreapplication.html#aboutToQuit">aboutToQuit</a>(), and <a href="../qtgui/qguiapplication.html#lastWindowClosed">QGuiApplication::lastWindowClosed</a>().</p>
<!-- @@@quit -->
<!-- $$$removeLibraryPath[overload1]$$$removeLibraryPathconstQString& -->
<h3 class="fn" id="removeLibraryPath"><a name="removeLibraryPath"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">removeLibraryPath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i>)</h3>
<p>Removes <i>path</i> from the library path list. If <i>path</i> is empty or not in the path list, the list is not changed.</p>
<p>The library paths are reset to the default when an instance of <a href="qcoreapplication.html">QCoreApplication</a> is destructed.</p>
<p><b>See also </b><a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>(), and <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>().</p>
<!-- @@@removeLibraryPath -->
<!-- $$$removeNativeEventFilter[overload1]$$$removeNativeEventFilterQAbstractNativeEventFilter* -->
<h3 class="fn" id="removeNativeEventFilter"><a name="removeNativeEventFilter"></a><span class="type">void</span> QCoreApplication::<span class="name">removeNativeEventFilter</span>(<span class="type"><a href="qabstractnativeeventfilter.html">QAbstractNativeEventFilter</a></span> *<i>filterObject</i>)</h3>
<p>Removes an event <i>filterObject</i> from this object. The request is ignored if such an event filter has not been installed.</p>
<p>All event filters for this object are automatically removed when this object is destroyed.</p>
<p>It is always safe to remove an event filter, even during event filter activation (i.e&#x2e; from the nativeEventFilter() function).</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qcoreapplication.html#installNativeEventFilter">installNativeEventFilter</a>().</p>
<!-- @@@removeNativeEventFilter -->
<!-- $$$removePostedEvents[overload1]$$$removePostedEventsQObject*int -->
<h3 class="fn" id="removePostedEvents"><a name="removePostedEvents"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">removePostedEvents</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, <span class="type">int</span> <i>eventType</i> = 0)</h3>
<p>Removes all events of the given <i>eventType</i> that were posted using <a href="qcoreapplication.html#postEvent">postEvent</a>() for <i>receiver</i>.</p>
<p>The events are <i>not</i> dispatched, instead they are removed from the queue. You should never need to call this function. If you do call it, be aware that killing events may cause <i>receiver</i> to break one or more invariants.</p>
<p>If <i>receiver</i> is null, the events of <i>eventType</i> are removed for all objects. If <i>eventType</i> is 0, all the events are removed for <i>receiver</i>. You should never call this function with <i>eventType</i> of 0. If you do call it in this way, be aware that killing events may cause <i>receiver</i> to break one or more invariants.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p>This function was introduced in  Qt 4.3.</p>
<!-- @@@removePostedEvents -->
<!-- $$$removeTranslator[overload1]$$$removeTranslatorQTranslator* -->
<h3 class="fn" id="removeTranslator"><a name="removeTranslator"></a><code>[static] </code><span class="type">bool</span> QCoreApplication::<span class="name">removeTranslator</span>(<span class="type"><a href="qtranslator.html">QTranslator</a></span> *<i>translationFile</i>)</h3>
<p>Removes the translation file <i>translationFile</i> from the list of translation files used by this application. (It does not delete the translation file from the file system.)</p>
<p>The function returns <code>true</code> on success and false on failure.</p>
<p><b>See also </b><a href="qcoreapplication.html#installTranslator">installTranslator</a>(), <a href="qcoreapplication.html#translate">translate</a>(), and <a href="qobject.html#tr">QObject::tr</a>().</p>
<!-- @@@removeTranslator -->
<!-- $$$sendEvent[overload1]$$$sendEventQObject*QEvent* -->
<h3 class="fn" id="sendEvent"><a name="sendEvent"></a><code>[static] </code><span class="type">bool</span> QCoreApplication::<span class="name">sendEvent</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, <span class="type"><a href="qevent.html">QEvent</a></span> *<i>event</i>)</h3>
<p>Sends event <i>event</i> directly to receiver <i>receiver</i>, using the <a href="qcoreapplication.html#notify">notify</a>() function. Returns the value that was returned from the event handler.</p>
<p>The event is <i>not</i> deleted when the event has been sent. The normal approach is to create the event on the stack, for example:</p>
<pre class="cpp">

  <span class="type"><a href="../qtgui/qmouseevent.html">QMouseEvent</a></span> event(<span class="type"><a href="qevent.html">QEvent</a></span><span class="operator">::</span>MouseButtonPress<span class="operator">,</span> pos<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
  <span class="type"><a href="../qtwidgets/qapplication.html">QApplication</a></span><span class="operator">::</span>sendEvent(mainWindow<span class="operator">,</span> <span class="operator">&amp;</span>event);

</pre>
<p><b>See also </b><a href="qcoreapplication.html#postEvent">postEvent</a>() and <a href="qcoreapplication.html#notify">notify</a>().</p>
<!-- @@@sendEvent -->
<!-- $$$sendPostedEvents[overload1]$$$sendPostedEventsQObject*int -->
<h3 class="fn" id="sendPostedEvents"><a name="sendPostedEvents"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">sendPostedEvents</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i> = Q_NULLPTR, <span class="type">int</span> <i>event_type</i> = 0)</h3>
<p>Immediately dispatches all events which have been previously queued with <a href="qcoreapplication.html#postEvent">QCoreApplication::postEvent</a>() and which are for the object <i>receiver</i> and have the event type <i>event_type</i>.</p>
<p>Events from the window system are <i>not</i> dispatched by this function, but by <a href="qcoreapplication.html#processEvents">processEvents</a>().</p>
<p>If <i>receiver</i> is null, the events of <i>event_type</i> are sent for all objects. If <i>event_type</i> is 0, all the events are sent for <i>receiver</i>.</p>
<p><b>Note: </b>This method must be called from the thread in which its <a href="qobject.html">QObject</a> parameter, <i>receiver</i>, lives.</p><p><b>See also </b><a href="qcoreapplication-obsolete.html#flush">flush</a>() and <a href="qcoreapplication.html#postEvent">postEvent</a>().</p>
<!-- @@@sendPostedEvents -->
<!-- $$$setAttribute[overload1]$$$setAttributeQt::ApplicationAttributebool -->
<h3 class="fn" id="setAttribute"><a name="setAttribute"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">setAttribute</span>(<span class="type"><a href="qt.html#ApplicationAttribute-enum">Qt::ApplicationAttribute</a></span> <i>attribute</i>, <span class="type">bool</span> <i>on</i> = true)</h3>
<p>Sets the attribute <i>attribute</i> if <i>on</i> is true; otherwise clears the attribute.</p>
<p><b>See also </b><a href="qcoreapplication.html#testAttribute">testAttribute</a>().</p>
<!-- @@@setAttribute -->
<!-- $$$setEventDispatcher[overload1]$$$setEventDispatcherQAbstractEventDispatcher* -->
<h3 class="fn" id="setEventDispatcher"><a name="setEventDispatcher"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">setEventDispatcher</span>(<span class="type"><a href="qabstracteventdispatcher.html">QAbstractEventDispatcher</a></span> *<i>eventDispatcher</i>)</h3>
<p>Sets the event dispatcher for the main thread to <i>eventDispatcher</i>. This is only possible as long as there is no event dispatcher installed yet. That is, before <a href="qcoreapplication.html">QCoreApplication</a> has been instantiated. This method takes ownership of the object.</p>
<p><b>See also </b><a href="qcoreapplication.html#eventDispatcher">eventDispatcher</a>().</p>
<!-- @@@setEventDispatcher -->
<!-- $$$setLibraryPaths[overload1]$$$setLibraryPathsconstQStringList& -->
<h3 class="fn" id="setLibraryPaths"><a name="setLibraryPaths"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">setLibraryPaths</span>(const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp;<i>paths</i>)</h3>
<p>Sets the list of directories to search when loading libraries to <i>paths</i>. All existing paths will be deleted and the path list will consist of the paths given in <i>paths</i>.</p>
<p>The library paths are reset to the default when an instance of <a href="qcoreapplication.html">QCoreApplication</a> is destructed.</p>
<p><b>See also </b><a href="qcoreapplication.html#libraryPaths">libraryPaths</a>(), <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>(), and <a href="qlibrary.html">QLibrary</a>.</p>
<!-- @@@setLibraryPaths -->
<!-- $$$setSetuidAllowed[overload1]$$$setSetuidAllowedbool -->
<h3 class="fn" id="setSetuidAllowed"><a name="setSetuidAllowed"></a><code>[static] </code><span class="type">void</span> QCoreApplication::<span class="name">setSetuidAllowed</span>(<span class="type">bool</span> <i>allow</i>)</h3>
<p>Allows the application to run setuid on UNIX platforms if <i>allow</i> is true.</p>
<p>If <i>allow</i> is false (the default) and Qt detects the application is running with an effective user id different than the real user id, the application will be aborted when a <a href="qcoreapplication.html">QCoreApplication</a> instance is created.</p>
<p>Qt is not an appropriate solution for setuid programs due to its large attack surface. However some applications may be required to run in this manner for historical reasons. This flag will prevent Qt from aborting the application when this is detected, and must be set before a <a href="qcoreapplication.html">QCoreApplication</a> instance is created.</p>
<p><b>Note: </b>It is strongly recommended not to enable this option since it introduces security risks.</p><p>This function was introduced in  Qt 5.3.</p>
<p><b>See also </b><a href="qcoreapplication.html#isSetuidAllowed">isSetuidAllowed</a>().</p>
<!-- @@@setSetuidAllowed -->
<!-- $$$startingUp[overload1]$$$startingUp -->
<h3 class="fn" id="startingUp"><a name="startingUp"></a><code>[static] </code><span class="type">bool</span> QCoreApplication::<span class="name">startingUp</span>()</h3>
<p>Returns <code>true</code> if an application object has not been created yet; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qcoreapplication.html#closingDown">closingDown</a>().</p>
<!-- @@@startingUp -->
<!-- $$$testAttribute[overload1]$$$testAttributeQt::ApplicationAttribute -->
<h3 class="fn" id="testAttribute"><a name="testAttribute"></a><code>[static] </code><span class="type">bool</span> QCoreApplication::<span class="name">testAttribute</span>(<span class="type"><a href="qt.html#ApplicationAttribute-enum">Qt::ApplicationAttribute</a></span> <i>attribute</i>)</h3>
<p>Returns <code>true</code> if attribute <i>attribute</i> is set; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qcoreapplication.html#setAttribute">setAttribute</a>().</p>
<!-- @@@testAttribute -->
<!-- $$$translate[overload1]$$$translateconstchar*constchar*constchar*int -->
<h3 class="fn" id="translate"><a name="translate"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QCoreApplication::<span class="name">translate</span>(const <span class="type">char</span> *<i>context</i>, const <span class="type">char</span> *<i>sourceText</i>, const <span class="type">char</span> *<i>disambiguation</i> = Q_NULLPTR, <span class="type">int</span> <i>n</i> = -1)</h3>
<p>Returns the translation text for <i>sourceText</i>, by querying the installed translation files. The translation files are searched from the most recently installed file back to the first installed file.</p>
<p><a href="qobject.html#tr">QObject::tr</a>() provides this functionality more conveniently.</p>
<p><i>context</i> is typically a class name (e.g&#x2e;, &quot;MyDialog&quot;) and <i>sourceText</i> is either English text or a short identifying text.</p>
<p><i>disambiguation</i> is an identifying string, for when the same <i>sourceText</i> is used in different roles within the same context. By default, it is null.</p>
<p>See the <a href="qtranslator.html">QTranslator</a> and <a href="qobject.html#tr">QObject::tr</a>() documentation for more information about contexts, disambiguations and comments.</p>
<p><i>n</i> is used in conjunction with <code>%n</code> to support plural forms. See <a href="qobject.html#tr">QObject::tr</a>() for details.</p>
<p>If none of the translation files contain a translation for <i>sourceText</i> in <i>context</i>, this function returns a <a href="qstring.html">QString</a> equivalent of <i>sourceText</i>.</p>
<p>This function is not virtual. You can use alternative translation techniques by subclassing <a href="qtranslator.html">QTranslator</a>.</p>
<p><b>Warning:</b> This method is reentrant only if all translators are installed <i>before</i> calling this method. Installing or removing translators while performing translations is not supported. Doing so will most likely result in crashes or other undesirable behavior.</p>
<p><b>Note:</b> This function is reentrant.</p>
<p><b>See also </b><a href="qobject.html#tr">QObject::tr</a>() and <a href="qcoreapplication.html#installTranslator">installTranslator</a>().</p>
<!-- @@@translate -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$qAddPostRoutine[overload1]$$$qAddPostRoutineQtCleanUpFunction -->
<h3 class="fn" id="qAddPostRoutine"><a name="qAddPostRoutine"></a><span class="type">void</span> <span class="name">qAddPostRoutine</span>(<span class="type">QtCleanUpFunction</span> <i>ptr</i>)</h3>
<p>Adds a global routine that will be called from the <a href="qcoreapplication.html">QCoreApplication</a> destructor. This function is normally used to add cleanup routines for program-wide functionality.</p>
<p>The cleanup routines are called in the reverse order of their addition.</p>
<p>The function specified by <i>ptr</i> should take no arguments and should return nothing. For example:</p>
<pre class="cpp">

  <span class="keyword">static</span> <span class="type">int</span> <span class="operator">*</span>global_ptr <span class="operator">=</span> <span class="number">0</span>;

  <span class="keyword">static</span> <span class="type">void</span> cleanup_ptr()
  {
      <span class="keyword">delete</span> <span class="operator">[</span><span class="operator">]</span> global_ptr;
      global_ptr <span class="operator">=</span> <span class="number">0</span>;
  }

  <span class="type">void</span> init_ptr()
  {
      global_ptr <span class="operator">=</span> <span class="keyword">new</span> <span class="type">int</span><span class="operator">[</span><span class="number">100</span><span class="operator">]</span>;      <span class="comment">// allocate data</span>
      qAddPostRoutine(cleanup_ptr);   <span class="comment">// delete later</span>
  }

</pre>
<p>Note that for an application- or module-wide cleanup, qaddPostRoutine() is often not suitable. For example, if the program is split into dynamically loaded modules, the relevant module may be unloaded long before the <a href="qcoreapplication.html">QCoreApplication</a> destructor is called. In such cases, if using qaddPostRoutine() is still desirable, <a href="qcoreapplication.html#qRemovePostRoutine">qRemovePostRoutine</a>() can be used to prevent a routine from being called by the <a href="qcoreapplication.html">QCoreApplication</a> destructor. For example, if that routine was called before the module was unloaded.</p>
<p>For modules and libraries, using a reference-counted initialization manager or Qt's parent-child deletion mechanism may be better. Here is an example of a private class that uses the parent-child mechanism to call a cleanup function at the right time:</p>
<pre class="cpp">

  <span class="keyword">class</span> MyPrivateInitStuff : <span class="keyword">public</span> <span class="type"><a href="qobject.html">QObject</a></span>
  {
  <span class="keyword">public</span>:
      <span class="keyword">static</span> MyPrivateInitStuff <span class="operator">*</span>initStuff(<span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>parent)
      {
          <span class="keyword">if</span> (<span class="operator">!</span>p)
              p <span class="operator">=</span> <span class="keyword">new</span> MyPrivateInitStuff(parent);
          <span class="keyword">return</span> p;
      }

      <span class="operator">~</span>MyPrivateInitStuff()
      {
          <span class="comment">// cleanup goes here</span>
      }

  <span class="keyword">private</span>:
      MyPrivateInitStuff(<span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>parent)
          : <span class="type"><a href="qobject.html">QObject</a></span>(parent)
      {
          <span class="comment">// initialization goes here</span>
      }

      MyPrivateInitStuff <span class="operator">*</span>p;
  };

</pre>
<p>By selecting the right parent object, this can often be made to clean up the module's data at the right moment.</p>
<p><b>See also </b><a href="qcoreapplication.html#qRemovePostRoutine">qRemovePostRoutine</a>().</p>
<!-- @@@qAddPostRoutine -->
<!-- $$$qRemovePostRoutine[overload1]$$$qRemovePostRoutineQtCleanUpFunction -->
<h3 class="fn" id="qRemovePostRoutine"><a name="qRemovePostRoutine"></a><span class="type">void</span> <span class="name">qRemovePostRoutine</span>(<span class="type">QtCleanUpFunction</span> <i>ptr</i>)</h3>
<p>Removes the cleanup routine specified by <i>ptr</i> from the list of routines called by the <a href="qcoreapplication.html">QCoreApplication</a> destructor. The routine must have been previously added to the list by a call to <a href="qcoreapplication.html#qAddPostRoutine">qAddPostRoutine</a>(), otherwise this function has no effect.</p>
<p>This function was introduced in  Qt 5.3.</p>
<p><b>See also </b><a href="qcoreapplication.html#qAddPostRoutine">qAddPostRoutine</a>().</p>
<!-- @@@qRemovePostRoutine -->
</div>
<div class="macros">
<h2>Macro Documentation</h2>
<!-- $$$Q_COREAPP_STARTUP_FUNCTION[overload1]$$$Q_COREAPP_STARTUP_FUNCTIONQtStartUpFunction -->
<h3 class="fn" id="Q_COREAPP_STARTUP_FUNCTION"><a name="Q_COREAPP_STARTUP_FUNCTION"></a><span class="name">Q_COREAPP_STARTUP_FUNCTION</span>(<span class="type">QtStartUpFunction</span> <i>ptr</i>)</h3>
<p>Adds a global function that will be called from the <a href="qcoreapplication.html">QCoreApplication</a> constructor. This macro is normally used to initialize libraries for program-wide functionality, without requiring the application to call into the library for initialization.</p>
<p>The function specified by <i>ptr</i> should take no arguments and should return nothing. For example:</p>
<pre class="cpp">

  <span class="comment">// Called once QCoreApplication exists</span>
  <span class="keyword">static</span> <span class="type">void</span> preRoutineMyDebugTool()
  {
      MyDebugTool<span class="operator">*</span> tool <span class="operator">=</span> <span class="keyword">new</span> MyDebugTool(<span class="type"><a href="qcoreapplication.html">QCoreApplication</a></span><span class="operator">::</span>instance());
      <span class="type"><a href="qcoreapplication.html">QCoreApplication</a></span><span class="operator">::</span>instance()<span class="operator">-</span><span class="operator">&gt;</span>installEventFilter(tool);
  }

  Q_COREAPP_STARTUP_FUNCTION(preRoutineMyDebugTool)

</pre>
<p>Note that the startup function will run at the end of the <a href="qcoreapplication.html">QCoreApplication</a> constructor, before any GUI initialization. If GUI code is required in the function, use a timer (or a queued invocation) to perform the initialization later on, from the event loop.</p>
<p>If <a href="qcoreapplication.html">QCoreApplication</a> is deleted and another <a href="qcoreapplication.html">QCoreApplication</a> is created, the startup function will be invoked again.</p>
<p><b>Note:</b> This function is reentrant.</p>
<p>This function was introduced in  Qt 5.1.</p>
<!-- @@@Q_COREAPP_STARTUP_FUNCTION -->
<!-- $$$Q_DECLARE_TR_FUNCTIONS[overload1]$$$Q_DECLARE_TR_FUNCTIONS -->
<h3 class="fn" id="Q_DECLARE_TR_FUNCTIONS"><a name="Q_DECLARE_TR_FUNCTIONS"></a><span class="name">Q_DECLARE_TR_FUNCTIONS</span>(<i>context</i>)</h3>
<p>The Q_DECLARE_TR_FUNCTIONS() macro declares and implements two translation functions, <code>tr()</code> and <code>trUtf8()</code>, with these signatures:</p>
<pre class="cpp">

  <span class="keyword">static</span> <span class="keyword">inline</span> <span class="type"><a href="qstring.html">QString</a></span> tr(<span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>sourceText<span class="operator">,</span>
                           <span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>comment <span class="operator">=</span> <span class="number">0</span>);
  <span class="keyword">static</span> <span class="keyword">inline</span> <span class="type"><a href="qstring.html">QString</a></span> trUtf8(<span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>sourceText<span class="operator">,</span>
                               <span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>comment <span class="operator">=</span> <span class="number">0</span>);

</pre>
<p>This macro is useful if you want to use <a href="qobject.html#tr">QObject::tr</a>() or QObject::trUtf8() in classes that don't inherit from <a href="qobject.html">QObject</a>.</p>
<p>Q_DECLARE_TR_FUNCTIONS() must appear at the very top of the class definition (before the first <code>public:</code> or <code>protected:</code>). For example:</p>
<pre class="cpp">

  <span class="keyword">class</span> MyMfcView : <span class="keyword">public</span> CView
  {
      Q_DECLARE_TR_FUNCTIONS(MyMfcView)

  <span class="keyword">public</span>:
      MyMfcView();
      <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  };

</pre>
<p>The <i>context</i> parameter is normally the class name, but it can be any text.</p>
<p><b>See also </b><a href="qobject.html#Q_OBJECT">Q_OBJECT</a>, <a href="qobject.html#tr">QObject::tr</a>(), and <a href="qobject-obsolete.html#trUtf8">QObject::trUtf8</a>().</p>
<!-- @@@Q_DECLARE_TR_FUNCTIONS -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>