QCoreApplication¶
The
QCoreApplicationclass provides an event loop for Qt applications without UI. More…

Inherited by: QGuiApplication, QApplication
Synopsis¶
Functions¶
def
installNativeEventFilter(filterObj)def
removeNativeEventFilter(filterObj)def
shutdown()
Virtual functions¶
def
notify(arg__1, arg__2)
Signals¶
def
applicationNameChanged()def
applicationVersionChanged()def
organizationDomainChanged()def
organizationNameChanged()
Static functions¶
def
addLibraryPath(arg__1)def
applicationDirPath()def
applicationFilePath()def
applicationName()def
applicationPid()def
applicationVersion()def
arguments()def
closingDown()def
eventDispatcher()def
exec_()def
exit([retcode=0])def
flush()def
hasPendingEvents()def
installTranslator(messageFile)def
instance()def
isQuitLockEnabled()def
isSetuidAllowed()def
libraryPaths()def
organizationDomain()def
organizationName()def
postEvent(receiver, event[, priority=Qt.NormalEventPriority])def
processEvents([flags=QEventLoop.AllEvents])def
processEvents(flags, maxtime)def
quit()def
removeLibraryPath(arg__1)def
removePostedEvents(receiver[, eventType=0])def
removeTranslator(messageFile)def
sendEvent(receiver, event)def
sendPostedEvents([receiver=None[, event_type=0]])def
setApplicationName(application)def
setApplicationVersion(version)def
setAttribute(attribute[, on=true])def
setEventDispatcher(eventDispatcher)def
setLibraryPaths(arg__1)def
setOrganizationDomain(orgDomain)def
setOrganizationName(orgName)def
setQuitLockEnabled(enabled)def
setSetuidAllowed(allow)def
startingUp()def
testAttribute(attribute)def
translate(context, key[, disambiguation=None[, n=-1]])
Detailed Description¶
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
QCoreApplicationobject. For GUI applications, seeQGuiApplication. For applications that use the Qt Widgets module, seeQApplication.
QCoreApplicationcontains the main event loop, where all events from the operating system (e.g., timer and network events) and other sources are processed and dispatched. It also handles the application’s initialization and finalization, as well as system-wide and application-wide settings.
The Event Loop and Event Handling¶
The event loop is started with a call to
exec(). Long-running operations can callprocessEvents()to keep the application responsive.In general, we recommend that you create a
QCoreApplication,QGuiApplicationor aQApplicationobject in yourmain()function as early as possible.exec()will not return until the event loop exits; e.g., whenquit()is called.Several static convenience functions are also provided. The
QCoreApplicationobject is available frominstance(). Events can be sent withsendEvent()or posted to an event queue withpostEvent(). Pending events can be removed withremovePostedEvents()or dispatched withsendPostedEvents().The class provides a
quit()slot and anaboutToQuit()signal.
Application and Library Paths¶
An application has an
applicationDirPath()and anapplicationFilePath(). Library paths (seeQLibrary) can be retrieved withlibraryPaths()and manipulated bysetLibraryPaths(),addLibraryPath(), andremoveLibraryPath().
Internationalization and Translations¶
Translation files can be added or removed using
installTranslator()andremoveTranslator(). Application strings can be translated usingtranslate(). Thetr()andtrUtf8()functions are implemented in terms oftranslate().
Accessing Command Line Arguments¶
The command line arguments which are passed to
QCoreApplication‘s constructor should be accessed using thearguments()function.Note
QCoreApplicationremoves option-qmljsdebugger="...". It parses the argument ofqmljsdebugger, and then removes this option plus its argument.For more advanced command line option handling, create a
QCommandLineParser.
Locale Settings¶
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
setlocale(LC_NUMERIC,"C")right after initializingQApplication,QGuiApplicationorQCoreApplicationto reset the locale that is used for number formatting to “C”-locale.See also
QGuiApplicationQAbstractEventDispatcherQEventLoopSemaphores Example Wait Conditions Example
- class PySide2.QtCore.QCoreApplication¶
PySide2.QtCore.QCoreApplication(arg__1)
- Parameters:
arg__1 – list of strings
- PySide2.QtCore.QCoreApplication.ApplicationFlags¶
New in version 4.8.
- static PySide2.QtCore.QCoreApplication.addLibraryPath(arg__1)¶
- Parameters:
arg__1 – str
Prepends
pathto the beginning of the library path list, ensuring that it is searched for libraries first. Ifpathis empty or already in the path list, the path list is not changed.The default path list consists of a single entry, the installation directory for plugins. The default installation directory for plugins is
INSTALL/plugins, whereINSTALLis the directory where Qt was installed.The library paths are reset to the default when an instance of
QCoreApplicationis destructed.
- static PySide2.QtCore.QCoreApplication.applicationDirPath()¶
- Return type:
str
Returns the directory that contains the application executable.
For example, if you have installed Qt in the
C:\Qtdirectory, and you run theregexpexample, this function will return “C:/Qt/examples/tools/regexp”.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).
Warning
On Linux, this function will try to get the path from the
/procfile system. If that fails, it assumes thatargv[0]contains the absolute file name of the executable. The function also assumes that the current directory has not been changed by the application.See also
- static PySide2.QtCore.QCoreApplication.applicationFilePath()¶
- Return type:
str
Returns the file path of the application executable.
For example, if you have installed Qt in the
/usr/local/qtdirectory, and you run theregexpexample, this function will return “/usr/local/qt/examples/tools/regexp/regexp”.Warning
On Linux, this function will try to get the path from the
/procfile system. If that fails, it assumes thatargv[0]contains the absolute file name of the executable. The function also assumes that the current directory has not been changed by the application.See also
- static PySide2.QtCore.QCoreApplication.applicationName()¶
- Return type:
str
This property holds the name of this application.
The value is used by the
QSettingsclass when it is constructed using the empty constructor. This saves having to repeat this information each time aQSettingsobject is created.If not set, the application name defaults to the executable name (since 5.0).
- PySide2.QtCore.QCoreApplication.applicationNameChanged()¶
- static PySide2.QtCore.QCoreApplication.applicationPid()¶
- Return type:
int
Returns the current process ID for the application.
- static PySide2.QtCore.QCoreApplication.applicationVersion()¶
- Return type:
str
This property holds the version of this application.
If not set, the application version defaults to a platform-specific value determined from the main application executable or package (since Qt 5.9):
Platform
Source
Windows (classic desktop)
PRODUCTVERSION parameter of the VERSIONINFO resource
Universal Windows Platform
version attribute of the application package manifest
macOS, iOS, tvOS, watchOS
CFBundleVersion property of the information property list
Android
android:versionName property of the AndroidManifest.xml manifest element
On other platforms, the default is the empty string.
- PySide2.QtCore.QCoreApplication.applicationVersionChanged()¶
- static PySide2.QtCore.QCoreApplication.arguments()¶
- Return type:
list of strings
Returns the list of command-line arguments.
Usually .at(0) is the program name, .at(1) is the first argument, and .last() is the last argument. See the note below about Windows.
Calling this function is slow - you should store the result in a variable when parsing the command line.
Warning
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
fromLocal8Bit(); 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.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.
Otherwise, the are constructed from the return value of GetCommandLine() . As a result of this, the string given by .at(0) might not be the program name on Windows, depending on how the application was started.
See also
- static PySide2.QtCore.QCoreApplication.closingDown()¶
- Return type:
bool
Returns
trueif the application objects are being destroyed; otherwise returnsfalse.See also
- static PySide2.QtCore.QCoreApplication.eventDispatcher()¶
- Return type:
Returns a pointer to the event dispatcher object for the main thread. If no event dispatcher exists for the thread, this function returns
None.See also
- static PySide2.QtCore.QCoreApplication.exec_()¶
- Return type:
int
Enters the main event loop and waits until
exit()is called. Returns the value that was passed toexit()(which is 0 ifexit()is called viaquit()).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.
To make your application perform idle processing (by executing a special function whenever there are no pending events), use a
QTimerwith 0 timeout. More advanced idle processing schemes can be achieved usingprocessEvents().We recommend that you connect clean-up code to the
aboutToQuit()signal, instead of putting it in your application’smain()function because on some platforms the 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 themain()function after the call.See also
quit()exit()processEvents()exec()
- static PySide2.QtCore.QCoreApplication.exit([retcode=0])¶
- Parameters:
retcode – int
Tells the application to exit with a return code.
After this function has been called, the application leaves the main event loop and returns from the call to
exec(). Theexec()function returnsreturnCode. If the event loop is not running, this function does nothing.By convention, a
returnCodeof 0 means success, and any non-zero value indicates an error.It’s good practice to always connect signals to this slot using a
QueuedConnection. If a signal connected (non-queued) to this slot is emitted before control enters the main event loop (such as before “int main” callsexec()), the slot has no effect and the application never exits. Using a queued connection ensures that the slot will not be invoked until after control enters the main event loop.Note that unlike the C library function of the same name, this function does return to the caller – it is event processing that stops.
See also
quit()exec()
- static PySide2.QtCore.QCoreApplication.flush()¶
Note
This function is deprecated.
This function is equivalent to calling
QCoreApplication::eventDispatcher()->flush(), which also is deprecated, seeflush(). UsesendPostedEvents()andprocessEvents()for more fine-grained control of the event loop instead.Historically this functions was used to flush the platform-specific native event queues.
See also
- static PySide2.QtCore.QCoreApplication.hasPendingEvents()¶
- Return type:
bool
Note
This function is deprecated.
This function returns
trueif there are pending events; otherwise returnsfalse. Pending events can be either from the window system or posted events usingpostEvent().Note
this function is not thread-safe. It may only be called in the main thread and only if there are no other threads running in the application (including threads Qt starts for its own purposes).
See also
- PySide2.QtCore.QCoreApplication.installNativeEventFilter(filterObj)¶
- Parameters:
filterObj –
PySide2.QtCore.QAbstractNativeEventFilter
Installs an event filter
filterObjfor all native events received by the application in the main thread.The event filter
filterObjreceives events via itsnativeEventFilter()function, which is called for all native events received in the main thread.The
nativeEventFilter()function should return true if the event should be filtered, i.e. stopped. It should return false to allow normal Qt processing to continue: the native event can then be translated into aQEventand handled by the standard Qteventfiltering, e.g.installEventFilter().If multiple event filters are installed, the filter that was installed last is activated first.
Note
The filter function set here receives native messages, i.e. MSG or XCB event structs.
Note
Native event filters will be disabled in the application when the
AA_PluginApplicationattribute is set.For maximum portability, you should always try to use
QEventandinstallEventFilter()whenever possible.See also
- static PySide2.QtCore.QCoreApplication.installTranslator(messageFile)¶
- Parameters:
messageFile –
PySide2.QtCore.QTranslator- Return type:
bool
Adds the translation file
translationFileto the list of translation files to be used for translations.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.
Installing or removing a
QTranslator, or changing an installedQTranslatorgenerates aLanguageChangeevent for theQCoreApplicationinstance. AQApplicationinstance 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 thetr()function to the respective property setters. User-interface classes generated by Qt Designer provide aretranslateUi()function that can be called.The function returns
trueon success and false on failure.Note
QCoreApplicationdoes not take ownership oftranslationFile.See also
removeTranslator()translate()load()Dynamic Translation
- static PySide2.QtCore.QCoreApplication.instance()¶
- Return type:
Returns a pointer to the application’s
QCoreApplication(orQGuiApplication/QApplication) instance.If no instance has been allocated,
Noneis returned.
- static PySide2.QtCore.QCoreApplication.isQuitLockEnabled()¶
- Return type:
bool
This property holds Whether the use of the
QEventLoopLockerfeature can cause the application to quit..The default is
true.See also
QEventLoopLocker
- static PySide2.QtCore.QCoreApplication.isSetuidAllowed()¶
- Return type:
bool
Returns true if the application is allowed to run setuid on UNIX platforms.
See also
- static PySide2.QtCore.QCoreApplication.libraryPaths()¶
- Return type:
list of strings
Returns a list of paths that the application will search when dynamically loading libraries.
The return value of this function may change when a
QCoreApplicationis created. It is not recommended to call it before creating aQCoreApplication. The directory of the application executable (not the working directory) is part of the list if it is known. In order to make it known aQCoreApplicationhas to be constructed as it will useargv[0]to find it.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
QCoreApplicationis created. If it is not found when calling this function, the default library paths will be used.The list will include the installation directory for plugins if it exists (the default installation directory for plugins is
INSTALL/plugins, whereINSTALLis the directory where Qt was installed). The colon separated entries of theQT_PLUGIN_PATHenvironment variable are always added. The plugin installation directory (and its existence) may change when the directory of the application executable becomes known.If you want to iterate over the list, you can use the foreach pseudo-keyword:
for path in app.libraryPaths(): do_something(path)
See also
setLibraryPaths()addLibraryPath()removeLibraryPath()QLibraryHow to Create Qt Plugins
- PySide2.QtCore.QCoreApplication.notify(arg__1, arg__2)¶
- Parameters:
arg__1 –
PySide2.QtCore.QObjectarg__2 –
PySide2.QtCore.QEvent
- Return type:
bool
Sends
eventtoreceiver:receiver->event(event). 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.For certain types of events (e.g. mouse and key events), the event will be propagated to the receiver’s parent and so on up to the top-level object if the receiver is not interested in the event (i.e., it returns
false).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:
Reimplementing
paintEvent(),mousePressEvent()and so on. This is the most common, easiest, and least powerful way.Reimplementing this function. This is very powerful, providing complete control; but only one subclass can be active at a time.
Installing an event filter on
instance(). Such an event filter is able to process all events for all widgets, so it’s just as powerful as reimplementing ; furthermore, it’s possible to have more than one application-global event filter. Global event filters even see mouse events fordisabled widgets. Note that application event filters are only called for objects that live in the main thread.Reimplementing
event()(asQWidgetdoes). If you do this you get Tab key presses, and you get to see the events before any widget-specific event filters.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.
Future direction: 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.
Warning
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.
See also
- static PySide2.QtCore.QCoreApplication.organizationDomain()¶
- Return type:
str
This property holds the Internet domain of the organization that wrote this application.
The value is used by the
QSettingsclass when it is constructed using the empty constructor. This saves having to repeat this information each time aQSettingsobject is created.On Mac,
QSettingsuses as the organization if it’s not an empty string; otherwise it usesorganizationName(). On all other platforms,QSettingsusesorganizationName()as the organization.
- PySide2.QtCore.QCoreApplication.organizationDomainChanged()¶
- static PySide2.QtCore.QCoreApplication.organizationName()¶
- Return type:
str
This property holds the name of the organization that wrote this application.
The value is used by the
QSettingsclass when it is constructed using the empty constructor. This saves having to repeat this information each time aQSettingsobject is created.On Mac,
QSettingsusesorganizationDomain()as the organization if it’s not an empty string; otherwise it uses . On all other platforms,QSettingsuses as the organization.See also
- PySide2.QtCore.QCoreApplication.organizationNameChanged()¶
- static PySide2.QtCore.QCoreApplication.postEvent(receiver, event[, priority=Qt.NormalEventPriority])¶
- Parameters:
receiver –
PySide2.QtCore.QObjectevent –
PySide2.QtCore.QEventpriority – int
Adds the event
event, with the objectreceiveras the receiver of the event, to an event queue and returns immediately.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 not safe to access the event after it has been posted.
When control returns to the main event loop, all events that are stored in the queue will be sent using the
notify()function.Events are sorted in descending
priorityorder, i.e. events with a highpriorityare queued before events with a lowerpriority. Theprioritycan be any integer value, i.e. between INT_MAX and INT_MIN, inclusive; seeEventPriorityfor more details. Events with equalprioritywill be processed in the order posted.See also
sendEvent()notify()sendPostedEvents()EventPriority
- static PySide2.QtCore.QCoreApplication.processEvents([flags=QEventLoop.AllEvents])¶
- Parameters:
flags –
ProcessEventsFlags
Processes some pending events for the calling thread according to the specified
flags.You can call this function occasionally when your program is busy performing a long operation (e.g. copying a file).
In the event that you are running a local loop which calls this function continuously, without an event loop, the
DeferredDeleteevents will not be processed. This can affect the behaviour of widgets, e.g.QToolTip, that rely onDeferredDeleteevents to function properly. An alternative would be to callsendPostedEvents()from within that local loop.Calling this function processes events only for the calling thread, and returns after all available events have been processed. Available events are events queued before the function call. This means that events that are posted while the function runs will be queued until a later round of event processing.
See also
- static PySide2.QtCore.QCoreApplication.processEvents(flags, maxtime)
- Parameters:
flags –
ProcessEventsFlagsmaxtime – int
This function overloads
processEvents().Processes pending events for the calling thread for
msmilliseconds or until there are no more events to process, whichever is shorter.You can call this function occasionally when your program is busy doing a long operation (e.g. copying a file).
Calling this function processes events only for the calling thread.
Note
Unlike the
processEvents()overload, this function also processes events that are posted while the function runs.Note
All events that were queued before the timeout will be processed, however long it takes.
See also
exec()QTimerprocessEvents()
- static PySide2.QtCore.QCoreApplication.quit()¶
Tells the application to exit with return code 0 (success). Equivalent to calling
exit(0).It’s common to connect the
lastWindowClosed()signal to , and you also often connect e.g.clicked()or signals inQAction,QMenu, orQMenuBarto it.It’s good practice to always connect signals to this slot using a
QueuedConnection. If a signal connected (non-queued) to this slot is emitted before control enters the main event loop (such as before “int main” callsexec()), the slot has no effect and the application never exits. Using a queued connection ensures that the slot will not be invoked until after control enters the main event loop.Example:
quitButton = QPushButton("Quit") quitButton.clicked.connect(app.quit)
See also
exit()aboutToQuit()lastWindowClosed()
- static PySide2.QtCore.QCoreApplication.removeLibraryPath(arg__1)¶
- Parameters:
arg__1 – str
Removes
pathfrom the library path list. Ifpathis empty or not in the path list, the list is not changed.The library paths are reset to the default when an instance of
QCoreApplicationis destructed.
- PySide2.QtCore.QCoreApplication.removeNativeEventFilter(filterObj)¶
- Parameters:
filterObj –
PySide2.QtCore.QAbstractNativeEventFilter
Removes an event
filterObjectfrom this object. The request is ignored if such an event filter has not been installed.All event filters for this object are automatically removed when this object is destroyed.
It is always safe to remove an event filter, even during event filter activation (i.e. from the nativeEventFilter() function).
See also
- static PySide2.QtCore.QCoreApplication.removePostedEvents(receiver[, eventType=0])¶
- Parameters:
receiver –
PySide2.QtCore.QObjecteventType – int
Removes all events of the given
eventTypethat were posted usingpostEvent()forreceiver.The events are not 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
receiverto break one or more invariants.If
receiverisNone, the events ofeventTypeare removed for all objects. IfeventTypeis 0, all the events are removed forreceiver. You should never call this function witheventTypeof 0.
- static PySide2.QtCore.QCoreApplication.removeTranslator(messageFile)¶
- Parameters:
messageFile –
PySide2.QtCore.QTranslator- Return type:
bool
Removes the translation file
translationFilefrom the list of translation files used by this application. (It does not delete the translation file from the file system.)The function returns
trueon success and false on failure.See also
- static PySide2.QtCore.QCoreApplication.sendEvent(receiver, event)¶
- Parameters:
receiver –
PySide2.QtCore.QObjectevent –
PySide2.QtCore.QEvent
- Return type:
bool
Sends event
eventdirectly to receiverreceiver, using thenotify()function. Returns the value that was returned from the event handler.The event is not deleted when the event has been sent. The normal approach is to create the event on the stack, for example:
event = QMouseEvent(QEvent.MouseButtonPress, pos, 0, 0, 0) QApplication.sendEvent(mainWindow, event)
See also
- static PySide2.QtCore.QCoreApplication.sendPostedEvents([receiver=None[, event_type=0]])¶
- Parameters:
receiver –
PySide2.QtCore.QObjectevent_type – int
Immediately dispatches all events which have been previously queued with
postEvent()and which are for the objectreceiverand have the event typeevent_type.Events from the window system are not dispatched by this function, but by
processEvents().If
receiverisNone, the events ofevent_typeare sent for all objects. Ifevent_typeis 0, all the events are sent forreceiver.Note
This method must be called from the thread in which its
QObjectparameter,receiver, lives.See also
- static PySide2.QtCore.QCoreApplication.setApplicationName(application)¶
- Parameters:
application – str
This property holds the name of this application.
The value is used by the
QSettingsclass when it is constructed using the empty constructor. This saves having to repeat this information each time aQSettingsobject is created.If not set, the application name defaults to the executable name (since 5.0).
- static PySide2.QtCore.QCoreApplication.setApplicationVersion(version)¶
- Parameters:
version – str
This property holds the version of this application.
If not set, the application version defaults to a platform-specific value determined from the main application executable or package (since Qt 5.9):
Platform
Source
Windows (classic desktop)
PRODUCTVERSION parameter of the VERSIONINFO resource
Universal Windows Platform
version attribute of the application package manifest
macOS, iOS, tvOS, watchOS
CFBundleVersion property of the information property list
Android
android:versionName property of the AndroidManifest.xml manifest element
On other platforms, the default is the empty string.
- static PySide2.QtCore.QCoreApplication.setAttribute(attribute[, on=true])¶
- Parameters:
attribute –
ApplicationAttributeon – bool
Sets the attribute
attributeifonis true; otherwise clears the attribute.Note
Some application attributes must be set before creating a
QCoreApplicationinstance. Refer to theApplicationAttributedocumentation for more information.See also
- static PySide2.QtCore.QCoreApplication.setEventDispatcher(eventDispatcher)¶
- Parameters:
eventDispatcher –
PySide2.QtCore.QAbstractEventDispatcher
Sets the event dispatcher for the main thread to
eventDispatcher. This is only possible as long as there is no event dispatcher installed yet. That is, beforeQCoreApplicationhas been instantiated. This method takes ownership of the object.See also
- static PySide2.QtCore.QCoreApplication.setLibraryPaths(arg__1)¶
- Parameters:
arg__1 – list of strings
Sets the list of directories to search when loading plugins with
QLibrarytopaths. All existing paths will be deleted and the path list will consist of the paths given inpathsand the path to the application.The library paths are reset to the default when an instance of
QCoreApplicationis destructed.See also
libraryPaths()addLibraryPath()removeLibraryPath()QLibrary
- static PySide2.QtCore.QCoreApplication.setOrganizationDomain(orgDomain)¶
- Parameters:
orgDomain – str
This property holds the Internet domain of the organization that wrote this application.
The value is used by the
QSettingsclass when it is constructed using the empty constructor. This saves having to repeat this information each time aQSettingsobject is created.On Mac,
QSettingsuses as the organization if it’s not an empty string; otherwise it usesorganizationName(). On all other platforms,QSettingsusesorganizationName()as the organization.
- static PySide2.QtCore.QCoreApplication.setOrganizationName(orgName)¶
- Parameters:
orgName – str
This property holds the name of the organization that wrote this application.
The value is used by the
QSettingsclass when it is constructed using the empty constructor. This saves having to repeat this information each time aQSettingsobject is created.On Mac,
QSettingsusesorganizationDomain()as the organization if it’s not an empty string; otherwise it uses . On all other platforms,QSettingsuses as the organization.See also
- static PySide2.QtCore.QCoreApplication.setQuitLockEnabled(enabled)¶
- Parameters:
enabled – bool
This property holds Whether the use of the
QEventLoopLockerfeature can cause the application to quit..The default is
true.See also
QEventLoopLocker
- static PySide2.QtCore.QCoreApplication.setSetuidAllowed(allow)¶
- Parameters:
allow – bool
Allows the application to run setuid on UNIX platforms if
allowis true.If
allowis 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 aQCoreApplicationinstance is created.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
QCoreApplicationinstance is created.Note
It is strongly recommended not to enable this option since it introduces security risks.
See also
- PySide2.QtCore.QCoreApplication.shutdown()¶
- static PySide2.QtCore.QCoreApplication.startingUp()¶
- Return type:
bool
Returns
trueif an application object has not been created yet; otherwise returnsfalse.See also
- static PySide2.QtCore.QCoreApplication.testAttribute(attribute)¶
- Parameters:
attribute –
ApplicationAttribute- Return type:
bool
Returns
trueif attributeattributeis set; otherwise returnsfalse.See also
- static PySide2.QtCore.QCoreApplication.translate(context, key[, disambiguation=None[, n=-1]])¶
- Parameters:
context – str
key – str
disambiguation – str
n – int
- Return type:
str
Returns the translation text for
sourceText, by querying the installed translation files. The translation files are searched from the most recently installed file back to the first installed file.tr()provides this functionality more conveniently.contextis typically a class name (e.g., “MyDialog”) andsourceTextis either English text or a short identifying text.disambiguationis an identifying string, for when the samesourceTextis used in different roles within the same context. By default, it isNone.See the
QTranslatorandtr()documentation for more information about contexts, disambiguations and comments.nis used in conjunction with%nto support plural forms. Seetr()for details.If none of the translation files contain a translation for
sourceTextincontext, this function returns aQStringequivalent ofsourceText.This function is not virtual. You can use alternative translation techniques by subclassing
QTranslator.- class QCoreApplication(args)¶
Constructs a Qt kernel application. Kernel applications are applications without a graphical user interface. These type of applications are used at the console or as server processes.
The args argument is processed by the application, and made available in a more convenient form by the
arguments()method.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. 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.