Skip to content

PythonQt.Qt.QCoreApplication

QCoreApplication

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

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 QCoreApplication object. For GUI applications, see QGuiApplication. For applications that use the Qt Widgets module, see QApplication.

QCoreApplication contains the main event loop, where all events from the operating system (e.g., timer and network events) and other sources are processed and dispatched. It also handles the application's initialization and finalization, as well as system-wide and application-wide settings.

The Event Loop and Event Handling

The event loop is started with a call to exec(). Long-running operations can call processEvents() to keep the application responsive.

In general, we recommend that you create a QCoreApplication, QGuiApplication or a QApplication object in your main() function as early as possible. exec() will not return until the event loop exits; e.g., when quit() is called.

Several static convenience functions are also provided. The QCoreApplication object is available from instance(). Events can be sent with sendEvent() or posted to an event queue with postEvent(). Pending events can be removed with removePostedEvents() or dispatched with sendPostedEvents().

The class provides a quit() slot and an aboutToQuit() signal.

Application and Library Paths

An application has an applicationDirPath() and an applicationFilePath(). Library paths (see QLibrary) can be retrieved with libraryPaths() and manipulated by setLibraryPaths(), addLibraryPath(), and removeLibraryPath().

Internationalization and Translations

Translation files can be added or removed using installTranslator() and removeTranslator(). Application strings can be translated using translate(). The QObject::tr() and QObject::trUtf8() functions are implemented in terms of translate().

Accessing Command Line Arguments

The command line arguments which are passed to QCoreApplication's constructor should be accessed using the arguments() function.

Note: QCoreApplication removes option -qmljsdebugger="...". It parses the argument of qmljsdebugger, 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 initializing QApplication, QGuiApplication or QCoreApplication to reset the locale that is used for number formatting to "C"-locale.

Source: https://doc.qt.io/archives/qt-5.15/qcoreapplication.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
ApplicationFlags attribute Any (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
aboutToQuit function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QCoreApplication.aboutToQuit; argument details are not documented.
addLibraryPath function (self, arg__1: str) -> None Prepends path to the beginning of the library path list, ensuring that it is searched for libraries first. (shared captured text)
applicationDirPath function (self) -> str X.applicationDirPath() -> str (shared captured text)
applicationFilePath function (self) -> str X.applicationFilePath() -> str (shared captured text)
applicationName attribute str This property holds the name of this application (shared captured text)
applicationNameChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QCoreApplication.applicationNameChanged; argument details are not documented.
applicationPid function (self) -> int X.applicationPid() -> int (shared captured text)
applicationVersion attribute str This property holds the version of this application (shared captured text)
applicationVersionChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QCoreApplication.applicationVersionChanged; argument details are not documented.
arguments function (self) -> tuple X.arguments() -> tuple (shared captured text)
blockSignals function (self, b: Any) -> bool X.blockSignals(b) -> bool (shared captured text)
childEvent function (self, event: Any) -> Any (shared captured text)
children function (self) -> tuple X.children() -> tuple (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
closingDown function (self) -> bool X.closingDown() -> bool (shared captured text)
connect function (self, signal: Any, receiver: Any, slot: Any, type: Any) -> bool X.connect(signal, receiver, slot, type) -> bool (shared captured text)
customEvent function (self, event: Any) -> Any (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
deleteLater function (self) -> Any (shared captured text)
destroyed function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QCoreApplication.destroyed; argument details are not documented.
disconnect function (self, signal: Any, receiver: Any, slot: Any) -> bool X.disconnect(signal, receiver, slot) -> bool (shared captured text)
dumpObjectInfo function (self) -> Any (shared captured text)
dumpObjectTree function (self) -> Any (shared captured text)
dynamicPropertyNames function (self) -> Any (shared captured text)
enum_1 attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
event function (self, arg__1: Any) -> bool X.event(arg__1) -> bool (shared captured text)
eventDispatcher function (self) -> Any Returns a pointer to the event dispatcher object for the main thread. (shared captured text)
eventFilter function (self, watched: Any, event: Any) -> bool X.eventFilter(watched, event) -> bool (shared captured text)
exec function (self) -> int X.exec() -> int (shared captured text)
exit function (self, retcode: int) -> None Tells the application to exit with a return code. (shared captured text)
findChild function (self, type: Any, name: Any) -> Any X.findChild(type, name) -> PythonQt.private.QObject (shared captured text)
findChildren function (self, type: Any, name: Any) -> tuple X.findChildren(type, name) -> tuple (shared captured text)
flush function (self) -> None (shared captured text)
hasPendingEvents function (self) -> bool X.hasPendingEvents() -> bool (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
installEventFilter function (self, filterObj: Any) -> Any (shared captured text)
installTranslator function (self, messageFile: Any) -> bool X.installTranslator(messageFile) -> bool (shared captured text)
instance function (self) -> Any X.instance() -> PythonQt.QtCore.QCoreApplication (shared captured text)
isQuitLockEnabled function (self) -> bool X.isQuitLockEnabled() -> bool (shared captured text)
isSetuidAllowed function (self) -> bool X.isSetuidAllowed() -> bool (shared captured text)
isSignalConnected function (self, signal: Any) -> bool X.isSignalConnected(signal) -> bool (shared captured text)
isWidgetType function (self) -> bool X.isWidgetType() -> bool (shared captured text)
isWindowType function (self) -> bool X.isWindowType() -> bool (shared captured text)
killTimer function (self, id: Any) -> Any (shared captured text)
libraryPaths function (self) -> tuple X.libraryPaths() -> tuple (shared captured text)
metaObject function (self) -> Any X.metaObject() -> PythonQt.QtCore.QMetaObject (shared captured text)
moveToThread function (self, thread: Any) -> Any (shared captured text)
notify function (self, arg__1: Any, arg__2: Any) -> bool X.notify(arg__1, arg__2) -> bool (shared captured text)
objectName attribute Any (shared captured text)
objectNameChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QCoreApplication.objectNameChanged; argument details are not documented.
organizationDomain attribute str This property holds the Internet domain of the organization that wrote this application (shared captured text)
organizationDomainChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QCoreApplication.organizationDomainChanged; argument details are not documented.
organizationName attribute str This property holds the name of the organization that wrote this application (shared captured text)
organizationNameChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QCoreApplication.organizationNameChanged; argument details are not documented.
parent function (self) -> Any X.parent() -> PythonQt.private.QObject (shared captured text)
postEvent function (self, receiver: Any, event: Any, priority: int) -> None X.postEvent(receiver, event, priority) (shared captured text)
processEvents function (self, arg0: flags, maxtime: Any) -> None X.processEvents(flags, maxtime) (shared captured text)
property function (self, name: Any) -> Any X.property(name) -> object (shared captured text)
quit function (self) -> None Tells the application to exit with return code 0 (success). (shared captured text)
quitLockEnabled attribute Any This property holds whether the use of the [QEventLoopLocker](https://doc.qt.io/archives/qt-5.15/qeventlooplocker.html) feature can cause the application to quit. (shared captured text)
removeEventFilter function (self, obj: Any) -> Any (shared captured text)
removeLibraryPath function (self, arg__1: str) -> None Removes path from the library path list. (shared captured text)
removePostedEvents function (self, receiver: Any, eventType: int) -> None X.removePostedEvents(receiver, eventType) (shared captured text)
removeTranslator function (self, messageFile: Any) -> bool X.removeTranslator(messageFile) -> bool (shared captured text)
sendEvent function (self, receiver: Any, event: Any) -> bool X.sendEvent(receiver, event) -> bool (shared captured text)
sendPostedEvents function (self, receiver: Any, event_type: int) -> None X.sendPostedEvents(receiver, event_type) (shared captured text)
sender function (self) -> Any X.sender() -> PythonQt.private.QObject (shared captured text)
senderSignalIndex function (self) -> int X.senderSignalIndex() -> int (shared captured text)
setApplicationName function (self, application: str) -> None (shared captured text)
setApplicationVersion function (self, version: str) -> None (shared captured text)
setAttribute function (self, attribute: Any, on: bool) -> None X.setAttribute(attribute, on) (shared captured text)
setEventDispatcher function (self, eventDispatcher: Any) -> None Sets the event dispatcher for the main thread to eventDispatcher. (shared captured text)
setLibraryPaths function (self, arg__1: Any) -> None Sets the list of directories to search when loading plugins with [QLibrary](https://doc.qt.io/archives/qt-5.15/qlibrary.html) to paths. (shared captured text)
setObjectName function (self, name: Any) -> Any (shared captured text)
setOrganizationDomain function (self, orgDomain: str) -> None (shared captured text)
setOrganizationName function (self, orgName: str) -> None (shared captured text)
setParent function (self, parent: Any) -> Any (shared captured text)
setProperty function (self, name: Any, value: Any) -> bool X.setProperty(name, value) -> bool (shared captured text)
setQuitLockEnabled function (self, enabled: bool) -> None (shared captured text)
setSetuidAllowed function (self, allow: bool) -> None Allows the application to run setuid on UNIX platforms if allow is true. (shared captured text)
signalsBlocked function (self) -> bool X.signalsBlocked() -> bool (shared captured text)
startTimer function (self, interval: Any, timerType: Any) -> int X.startTimer(interval, timerType) -> int (shared captured text)
startingUp function (self) -> bool X.startingUp() -> bool (shared captured text)
testAttribute function (self, attribute: Any) -> bool X.testAttribute(attribute) -> bool (shared captured text)
thread function (self) -> Any (shared captured text)
timerEvent function (self, event: Any) -> Any (shared captured text)
tr function (self, text: Any, ambig: Any, n: Any) -> str X.tr(text, ambig, n) -> str (shared captured text)
translate function (self, context: str, key: str, disambiguation: Any, n: int) -> str X.translate(context, key, disambiguation, n) -> str (shared captured text)