Skip to content

PythonQt.Qt.QGuiApplication

QGuiApplication

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

QGuiApplication contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the application's initialization and finalization, and provides session management. In addition, QGuiApplication handles most of the system-wide and application-wide settings.

For any GUI application using Qt, there is precisely one QGuiApplication object no matter whether the application has 0, 1, 2 or more windows at any given time. For non-GUI Qt applications, use QCoreApplication instead, as it does not depend on the Qt GUI module. For QWidget based Qt applications, use QApplication instead, as it provides some functionality needed for creating QWidget instances.

The QGuiApplication object is accessible through the instance() function, which returns a pointer equivalent to the global qApp pointer.

QGuiApplication's main areas of responsibility are:

  • It initializes the application with the user's desktop settings, such as palette(), font() and styleHints(). It keeps track of these properties in case the user changes the desktop globally, for example, through some kind of control panel.
  • It performs event handling, meaning that it receives events from the underlying window system and dispatches them to the relevant widgets. You can send your own events to windows by using sendEvent() and postEvent().
  • It parses common command line arguments and sets its internal state accordingly. See the constructor documentation below for more details.
  • It provides localization of strings that are visible to the user via translate().
  • It provides some magical objects like the clipboard().
  • It knows about the application's windows. You can ask which window is at a certain position using topLevelAt(), get a list of topLevelWindows(), etc.
  • It manages the application's mouse cursor handling, see setOverrideCursor()
  • It provides support for sophisticated session management. This makes it possible for applications to terminate gracefully when the user logs out, to cancel a shutdown process if termination isn't possible and even to preserve the entire application's state for a future session. See isSessionRestored(), sessionId() and commitDataRequest() and saveStateRequest() for details.

Since the QGuiApplication object does so much initialization, it must be created before any other objects related to the user interface are created. QGuiApplication also deals with common command line arguments. Hence, it is usually a good idea to create it before any interpretation or modification of argv is done in the application itself.

Groups of functions
System settings desktopSettingsAware(), setDesktopSettingsAware(), styleHints(), palette(), setPalette(), font(), setFont().
Event handling exec(), processEvents(), exit(), quit(). sendEvent(), postEvent(), sendPostedEvents(), removePostedEvents(), hasPendingEvents(), notify().
Windows allWindows(), topLevelWindows(), focusWindow(), clipboard(), topLevelAt().
Advanced cursor handling overrideCursor(), setOverrideCursor(), restoreOverrideCursor().
Session management isSessionRestored(), sessionId(), commitDataRequest(), saveStateRequest().
Miscellaneous startingUp(), closingDown().

Source: https://doc.qt.io/archives/qt-5.15/qguiapplication.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.QGuiApplication.aboutToQuit; argument details are not documented.
addLibraryPath function (self, arg__1: Any) -> Any (shared captured text)
allWindows function (self) -> tuple X.allWindows() -> tuple (shared captured text)
applicationDirPath function (self) -> str X.applicationDirPath() -> str (shared captured text)
applicationDisplayName attribute str This property holds the user-visible name of this application (shared captured text)
applicationDisplayNameChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.applicationDisplayNameChanged; argument details are not documented.
applicationFilePath function (self) -> str X.applicationFilePath() -> str (shared captured text)
applicationName attribute Any (shared captured text)
applicationNameChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.applicationNameChanged; argument details are not documented.
applicationPid function (self) -> int X.applicationPid() -> int (shared captured text)
applicationState function (self) -> Any Returns the current state of the application. (shared captured text)
applicationStateChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.applicationStateChanged; argument details are not documented.
applicationVersion attribute Any (shared captured text)
applicationVersionChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.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)
changeOverrideCursor function (self, arg__1: Any) -> None Changes the currently active application override cursor to cursor. (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)
clipboard function (self) -> Any X.clipboard() -> PythonQt.QtGui.QClipboard (shared captured text)
closingDown function (self) -> bool X.closingDown() -> bool (shared captured text)
commitDataRequest function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.commitDataRequest; argument details are not documented.
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)
desktopFileName attribute str This property holds the base name of the desktop entry for this application (shared captured text)
desktopSettingsAware function (self) -> bool X.desktopSettingsAware() -> bool (shared captured text)
destroyed function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.destroyed; argument details are not documented.
devicePixelRatio function (self) -> float X.devicePixelRatio() -> float (shared captured text)
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 (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: Any) -> Any (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) -> Any (shared captured text)
focusObject function (self) -> Any X.focusObject() -> PythonQt.private.QObject (shared captured text)
focusObjectChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.focusObjectChanged; argument details are not documented.
focusWindow function (self) -> Any X.focusWindow() -> PythonQt.QtGui.QWindow (shared captured text)
focusWindowChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.focusWindowChanged; argument details are not documented.
font function (self) -> Any X.font() -> PythonQt.QtGui.QFont (shared captured text)
fontChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.fontChanged; argument details are not documented.
fontDatabaseChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.fontDatabaseChanged; argument details are not documented.
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)
inputMethod function (self) -> Any X.inputMethod() -> PythonQt.QtGui.QInputMethod (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)
isFallbackSessionManagementEnabled function (self) -> bool X.isFallbackSessionManagementEnabled() -> bool (shared captured text)
isLeftToRight function (self) -> bool X.isLeftToRight() -> bool (shared captured text)
isQuitLockEnabled function (self) -> bool X.isQuitLockEnabled() -> bool (shared captured text)
isRightToLeft function (self) -> bool X.isRightToLeft() -> bool (shared captured text)
isSavingSession function (self) -> bool X.isSavingSession() -> bool (shared captured text)
isSessionRestored function (self) -> bool X.isSessionRestored() -> 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)
keyboardModifiers function (self) -> Any Returns the current state of the modifier keys on the keyboard. (shared captured text)
killTimer function (self, id: Any) -> Any (shared captured text)
lastWindowClosed function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.lastWindowClosed; argument details are not documented.
layoutDirection attribute Any This property holds the default layout direction for this application (shared captured text)
layoutDirectionChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.layoutDirectionChanged; argument details are not documented.
libraryPaths function (self) -> tuple X.libraryPaths() -> tuple (shared captured text)
metaObject function (self) -> Any X.metaObject() -> PythonQt.QtCore.QMetaObject (shared captured text)
modalWindow function (self) -> Any X.modalWindow() -> PythonQt.QtGui.QWindow (shared captured text)
mouseButtons function (self) -> Any Returns the current state of the buttons on the mouse. (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.QGuiApplication.objectNameChanged; argument details are not documented.
organizationDomain attribute Any (shared captured text)
organizationDomainChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.organizationDomainChanged; argument details are not documented.
organizationName attribute Any (shared captured text)
organizationNameChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.organizationNameChanged; argument details are not documented.
overrideCursor function (self) -> Any X.overrideCursor() -> PythonQt.QtGui.QCursor (shared captured text)
palette function (self) -> Any X.palette() -> PythonQt.QtGui.QPalette (shared captured text)
paletteChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.paletteChanged; argument details are not documented.
parent function (self) -> Any X.parent() -> PythonQt.private.QObject (shared captured text)
platformName attribute str This property holds the name of the underlying platform plugin. (shared captured text)
postEvent function (self, receiver: Any, event: Any, priority: Any) -> Any X.postEvent(receiver, event, priority) (shared captured text)
primaryScreen attribute QScreen This property holds the primary (or default) screen of the application. (shared captured text)
primaryScreenChanged function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.primaryScreenChanged; argument details are not documented.
processEvents function (self, arg0: flags, maxtime: Any) -> Any X.processEvents(flags, maxtime) (shared captured text)
property function (self, name: Any) -> Any X.property(name) -> object (shared captured text)
queryKeyboardModifiers function (self) -> Any Queries and returns the state of the modifier keys on the keyboard. (shared captured text)
quit function (self) -> Any (shared captured text)
quitLockEnabled attribute Any (shared captured text)
quitOnLastWindowClosed attribute bool This property holds whether the application implicitly quits when the last window is closed. (shared captured text)
removeEventFilter function (self, obj: Any) -> Any (shared captured text)
removeLibraryPath function (self, arg__1: Any) -> Any (shared captured text)
removePostedEvents function (self, receiver: Any, eventType: Any) -> Any X.removePostedEvents(receiver, eventType) (shared captured text)
removeTranslator function (self, messageFile: Any) -> bool X.removeTranslator(messageFile) -> bool (shared captured text)
restoreOverrideCursor function (self) -> None Undoes the last [setOverrideCursor](https://doc.qt.io/archives/qt-5.15/qguiapplication.html#setOverrideCursor)(). (shared captured text)
saveStateRequest function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.saveStateRequest; argument details are not documented.
screenAdded function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.screenAdded; argument details are not documented.
screenRemoved function (self, *args: Any, **kwargs: Any) -> Any Native PythonQt.Qt.QGuiApplication.screenRemoved; argument details are not documented.
screens function (self) -> tuple X.screens() -> tuple (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: Any) -> Any 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)
sessionId function (self) -> str X.sessionId() -> str (shared captured text)
sessionKey function (self) -> str X.sessionKey() -> str (shared captured text)
setApplicationDisplayName function (self, name: str) -> None (shared captured text)
setApplicationName function (self, application: Any) -> Any (shared captured text)
setApplicationVersion function (self, version: Any) -> Any (shared captured text)
setAttribute function (self, attribute: Any, on: Any) -> Any X.setAttribute(attribute, on) (shared captured text)
setDesktopSettingsAware function (self, on: bool) -> None Sets whether Qt should use the system's standard colors, fonts, etc., to on. (shared captured text)
setEventDispatcher function (self, eventDispatcher: Any) -> Any (shared captured text)
setFallbackSessionManagementEnabled function (self, arg__1: bool) -> None Sets whether [QGuiApplication](https://doc.qt.io/archives/qt-5.15/qguiapplication.html) will use fallback session management to enabled. (shared captured text)
setFont function (self, arg__1: Any) -> None Changes the default application font to font. (shared captured text)
setLayoutDirection function (self, direction: Any) -> None (shared captured text)
setLibraryPaths function (self, arg__1: Any) -> Any (shared captured text)
setObjectName function (self, name: Any) -> Any (shared captured text)
setOrganizationDomain function (self, orgDomain: Any) -> Any (shared captured text)
setOrganizationName function (self, orgName: Any) -> Any (shared captured text)
setOverrideCursor function (self, arg__1: Any) -> None Sets the application override cursor to cursor. (shared captured text)
setPalette function (self, pal: Any) -> None Changes the application palette to pal. (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: Any) -> Any (shared captured text)
setQuitOnLastWindowClosed function (self, quit: bool) -> None (shared captured text)
setSetuidAllowed function (self, allow: Any) -> Any (shared captured text)
setWindowIcon function (self, icon: Any) -> None (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)
styleHints function (self) -> Any X.styleHints() -> PythonQt.QtGui.QStyleHints (shared captured text)
sync function (self) -> None Function that can be used to sync Qt state with the Window Systems state. (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)
topLevelAt function (self, pos: Any) -> Any X.topLevelAt(pos) -> PythonQt.QtGui.QWindow (shared captured text)
topLevelWindows function (self) -> tuple X.topLevelWindows() -> tuple (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: Any, key: Any, disambiguation: Any, n: Any) -> str X.translate(context, key, disambiguation, n) -> str (shared captured text)
windowIcon attribute QIcon This property holds the default window icon (shared captured text)