QtBase  v6.3.1
Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | Friends | List of all members
QGuiApplication Class Reference

The QGuiApplication class manages the GUI application's control flow and main settings. More...

#include <qguiapplication.h>

Inheritance diagram for QGuiApplication:
Inheritance graph
[legend]
Collaboration diagram for QGuiApplication:
Collaboration graph
[legend]

Signals

void fontDatabaseChanged ()
 
void screenAdded (QScreen *screen)
 
void screenRemoved (QScreen *screen)
 
void primaryScreenChanged (QScreen *screen)
 
void lastWindowClosed ()
 
void focusObjectChanged (QObject *focusObject)
 
void focusWindowChanged (QWindow *focusWindow)
 
void applicationStateChanged (Qt::ApplicationState state)
 
void layoutDirectionChanged (Qt::LayoutDirection direction)
 
void commitDataRequest (QSessionManager &sessionManager)
 
void saveStateRequest (QSessionManager &sessionManager)
 
void applicationDisplayNameChanged ()
 
- Signals inherited from QCoreApplication
void aboutToQuit (QPrivateSignal)
 
void organizationNameChanged ()
 
void organizationDomainChanged ()
 
void applicationNameChanged ()
 
void applicationVersionChanged ()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 

Public Member Functions

 QGuiApplication (int &argc, char **argv, int=ApplicationFlags)
 
 ~QGuiApplication ()
 
qreal devicePixelRatio () const
 
bool notify (QObject *, QEvent *) override
 
bool isSessionRestored () const
 
QString sessionId () const
 
QString sessionKey () const
 
bool isSavingSession () const
 
- Public Member Functions inherited from QCoreApplication
 QCoreApplication (int &argc, char **argv, int=ApplicationFlags)
 
 ~QCoreApplication ()
 
void installNativeEventFilter (QAbstractNativeEventFilter *filterObj)
 
void removeNativeEventFilter (QAbstractNativeEventFilter *filterObj)
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 

Static Public Member Functions

static void setApplicationDisplayName (const QString &name)
 
static QString applicationDisplayName ()
 
static void setDesktopFileName (const QString &name)
 
static QString desktopFileName ()
 
static QWindowList allWindows ()
 
static QWindowList topLevelWindows ()
 
static QWindowtopLevelAt (const QPoint &pos)
 
static void setWindowIcon (const QIcon &icon)
 
static QIcon windowIcon ()
 
static QString platformName ()
 
static QWindowmodalWindow ()
 
static QWindowfocusWindow ()
 
static QObjectfocusObject ()
 
static QScreenprimaryScreen ()
 
static QList< QScreen * > screens ()
 
static QScreenscreenAt (const QPoint &point)
 
static QCursoroverrideCursor ()
 
static void setOverrideCursor (const QCursor &)
 
static void changeOverrideCursor (const QCursor &)
 
static void restoreOverrideCursor ()
 
static QFont font ()
 
static void setFont (const QFont &)
 
static QClipboardclipboard ()
 
static QPalette palette ()
 
static void setPalette (const QPalette &pal)
 
static Qt::KeyboardModifiers keyboardModifiers ()
 
static Qt::KeyboardModifiers queryKeyboardModifiers ()
 
static Qt::MouseButtons mouseButtons ()
 
static void setLayoutDirection (Qt::LayoutDirection direction)
 
static Qt::LayoutDirection layoutDirection ()
 
static bool isRightToLeft ()
 
static bool isLeftToRight ()
 
static QStyleHintsstyleHints ()
 
static void setDesktopSettingsAware (bool on)
 
static bool desktopSettingsAware ()
 
static QInputMethodinputMethod ()
 
static QPlatformNativeInterfaceplatformNativeInterface ()
 
static QFunctionPointer platformFunction (const QByteArray &function)
 
static void setQuitOnLastWindowClosed (bool quit)
 
static bool quitOnLastWindowClosed ()
 
static Qt::ApplicationState applicationState ()
 
static void setHighDpiScaleFactorRoundingPolicy (Qt::HighDpiScaleFactorRoundingPolicy policy)
 
static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy ()
 
static int exec ()
 
static void sync ()
 
- Static Public Member Functions inherited from QCoreApplication
static QStringList arguments ()
 
static void setAttribute (Qt::ApplicationAttribute attribute, bool on=true)
 [95] More...
 
static bool testAttribute (Qt::ApplicationAttribute attribute)
 
static void setOrganizationDomain (const QString &orgDomain)
 
static QString organizationDomain ()
 
static void setOrganizationName (const QString &orgName)
 [11] More...
 
static QString organizationName ()
 
static void setApplicationName (const QString &application)
 
static QString applicationName ()
 
static void setApplicationVersion (const QString &version)
 
static QString applicationVersion ()
 
static void setSetuidAllowed (bool allow)
 
static bool isSetuidAllowed ()
 
static QCoreApplicationinstance ()
 
static int exec ()
 
static void processEvents (QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
 
static void processEvents (QEventLoop::ProcessEventsFlags flags, int maxtime)
 
static bool sendEvent (QObject *receiver, QEvent *event)
 
static void postEvent (QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
 
static void sendPostedEvents (QObject *receiver=nullptr, int event_type=0)
 
static void removePostedEvents (QObject *receiver, int eventType=0)
 
static QAbstractEventDispatchereventDispatcher ()
 
static void setEventDispatcher (QAbstractEventDispatcher *eventDispatcher)
 
static bool startingUp ()
 
static bool closingDown ()
 
static QString applicationDirPath ()
 
static QString applicationFilePath ()
 
static qint64 applicationPid () Q_DECL_CONST_FUNCTION
 
static bool installTranslator (QTranslator *messageFile)
 
static bool removeTranslator (QTranslator *messageFile)
 
static QString translate (const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
 
static bool isQuitLockEnabled ()
 
static void setQuitLockEnabled (bool enabled)
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 

Protected Member Functions

bool event (QEvent *) override
 
bool compressEvent (QEvent *, QObject *receiver, QPostEventList *) override
 
 QGuiApplication (QGuiApplicationPrivate &p)
 
- Protected Member Functions inherited from QCoreApplication
 QCoreApplication (QCoreApplicationPrivate &p)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Properties

QIcon windowIcon
 the default window icon More...
 
QString applicationDisplayName
 the user-visible name of this application More...
 
QString desktopFileName
 the base name of the desktop entry for this application More...
 
Qt::LayoutDirection layoutDirection
 the default layout direction for this application More...
 
QString platformName
 The name of the underlying platform plugin. More...
 
bool quitOnLastWindowClosed
 whether the application implicitly quits when the last window is closed. More...
 
QScreenprimaryScreen
 the primary (or default) screen of the application. More...
 
- Properties inherited from QCoreApplication
QString applicationName
 the name of this application More...
 
QString applicationVersion
 the version of this application More...
 
QString organizationName
 the name of the organization that wrote this application More...
 
QString organizationDomain
 the Internet domain of the organization that wrote this application More...
 
bool quitLockEnabled
 Whether the use of the QEventLoopLocker feature can cause the application to quit. More...
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Friends

class QFontDatabasePrivate
 
class QPlatformIntegration
 
class QPlatformSessionManager
 

Additional Inherited Members

- Public Types inherited from QCoreApplication
enum  { ApplicationFlags = QT_VERSION }
 
- Public Slots inherited from QCoreApplication
static void quit ()
 
static void exit (int retcode=0)
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

The QGuiApplication class manages the GUI application's control flow and main settings.

\macro qGuiApp

A global pointer referring to the unique application object. Only valid for use when that object is a QGuiApplication.

See also
QCoreApplication::instance(), qApp

\inmodule QtGui

Since
5.0

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 \l qApp pointer.

QGuiApplication's main areas of responsibility are: \list

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.

\table \header

\row

\row

\row

\row

\row

\row

See also
QCoreApplication, QAbstractEventDispatcher, QEventLoop

Definition at line 72 of file qguiapplication.h.

Constructor & Destructor Documentation

◆ QGuiApplication() [1/2]

QGuiApplication::QGuiApplication ( int &  argc,
char **  argv,
int  flags = ApplicationFlags 
)

Initializes the window system and constructs an application object with argc command line arguments in argv.

Warning
The data referred to by argc and argv must stay valid for the entire lifetime of the QGuiApplication object. In addition, argc must be greater than zero and argv must contain at least one valid character string.

The global qApp pointer refers to this application object. Only one application object should be created.

This application object must be constructed before any \l{QPaintDevice} {paint devices} (including pixmaps, bitmaps etc.).

Note
argc and argv might be changed as Qt removes command line arguments that it recognizes.

Definition at line 654 of file qguiapplication.cpp.

Here is the call graph for this function:

◆ ~QGuiApplication()

QGuiApplication::~QGuiApplication ( )

Destructs the application.

Definition at line 674 of file qguiapplication.cpp.

Here is the call graph for this function:

◆ QGuiApplication() [2/2]

QGuiApplication::QGuiApplication ( QGuiApplicationPrivate p)
protected

Definition at line 666 of file qguiapplication.cpp.

Member Function Documentation

◆ allWindows()

QWindowList QGuiApplication::allWindows ( )
static

Returns a list of all the windows in the application.

The list is empty if there are no windows.

See also
topLevelWindows()

Definition at line 998 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ applicationDisplayName()

static QString QGuiApplication::applicationDisplayName ( )
static

◆ applicationDisplayNameChanged

void QGuiApplication::applicationDisplayNameChanged ( )
signal
Here is the caller graph for this function:

◆ applicationState()

Qt::ApplicationState QGuiApplication::applicationState ( )
static
Since
5.2

Returns the current state of the application.

You can react to application state changes to perform actions such as stopping/resuming CPU-intensive tasks, freeing/loading resources or saving/restoring application data.

Definition at line 3659 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ applicationStateChanged

void QGuiApplication::applicationStateChanged ( Qt::ApplicationState  state)
signal
Since
5.2

This signal is emitted when the state of the application changes.

See also
applicationState()
Here is the caller graph for this function:

◆ changeOverrideCursor()

void QGuiApplication::changeOverrideCursor ( const QCursor cursor)
static

Changes the currently active application override cursor to cursor.

This function has no effect if setOverrideCursor() was not called.

See also
setOverrideCursor(), overrideCursor(), restoreOverrideCursor(), QWidget::setCursor()

Definition at line 3974 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clipboard()

QClipboard * QGuiApplication::clipboard ( )
static

Returns the object for interacting with the clipboard.

Definition at line 3309 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ commitDataRequest

void QGuiApplication::commitDataRequest ( QSessionManager manager)
signal
Since
4.2

This signal deals with \l{Session Management}{session management}. It is emitted when the QSessionManager wants the application to commit all its data.

Usually this means saving all open files, after getting permission from the user. Furthermore you may want to provide a means by which the user can cancel the shutdown.

You should not exit the application within this signal. Instead, the session manager may or may not do this afterwards, depending on the context.

Warning
Within this signal, no user interaction is possible, unless you ask the manager for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details and example usage.
Note
You should use Qt::DirectConnection when connecting to this signal.
See also
isSessionRestored(), sessionId(), saveStateRequest(), {Session Management}
Here is the caller graph for this function:

◆ compressEvent()

bool QGuiApplication::compressEvent ( QEvent event,
QObject receiver,
QPostEventList postedEvents 
)
overrideprotectedvirtual

Reimplemented from QCoreApplication.

Reimplemented in QApplication.

Definition at line 1996 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ desktopFileName()

static QString QGuiApplication::desktopFileName ( )
static

◆ desktopSettingsAware()

bool QGuiApplication::desktopSettingsAware ( )
static

Returns true if Qt is set to use the system's standard colors, fonts, etc.; otherwise returns false. The default is true.

See also
setDesktopSettingsAware()

Definition at line 4145 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ devicePixelRatio()

qreal QGuiApplication::devicePixelRatio ( ) const

Returns the highest screen device pixel ratio found on the system. This is the ratio between physical pixels and device-independent pixels.

Use this function only when you don't know which window you are targeting. If you do know the target window, use QWindow::devicePixelRatio() instead.

See also
QWindow::devicePixelRatio()

Definition at line 1125 of file qguiapplication.cpp.

Here is the call graph for this function:

◆ event()

bool QGuiApplication::event ( QEvent e)
overrideprotectedvirtual

\reimp

Reimplemented from QCoreApplication.

Reimplemented in MyApplication, and QApplication.

Definition at line 1960 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ exec()

int QGuiApplication::exec ( )
static

Enters the main event loop and waits until exit() is called, and then returns the value that was set to exit() (which is 0 if exit() is called via quit()).

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.

Generally, no user interaction can take place before calling exec().

To make your application perform idle processing, e.g., executing a special function whenever there are no pending events, use a QTimer with 0 timeout. More advanced idle processing schemes can be achieved using processEvents().

We recommend that you connect clean-up code to the \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your application's {main()} function. This is because, on some platforms, the QApplication::exec() call may not return.

See also
quitOnLastWindowClosed, quit(), exit(), processEvents(), QCoreApplication::exec()

Definition at line 1882 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ focusObject()

QObject * QGuiApplication::focusObject ( )
static

Returns the QObject in currently active window that will be final receiver of events tied to focus, such as key events.

Definition at line 982 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ focusObjectChanged

QGuiApplication::focusObjectChanged ( QObject focusObject)
signal

This signal is emitted when final receiver of events tied to focus is changed. focusObject is the new receiver.

See also
focusObject()
Here is the caller graph for this function:

◆ focusWindow()

QWindow * QGuiApplication::focusWindow ( )
static

Returns the QWindow that receives events tied to focus, such as key events.

Definition at line 955 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ focusWindowChanged

QGuiApplication::focusWindowChanged ( QWindow focusWindow)
signal

This signal is emitted when the focused window changes. focusWindow is the new focused window.

See also
focusWindow()

◆ font()

QFont QGuiApplication::font ( )
static

Returns the default application font.

See also
setFont()

Definition at line 3449 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fontDatabaseChanged

void QGuiApplication::fontDatabaseChanged ( )
signal

◆ highDpiScaleFactorRoundingPolicy()

Qt::HighDpiScaleFactorRoundingPolicy QGuiApplication::highDpiScaleFactorRoundingPolicy ( )
static
Since
5.14

Returns the high-DPI scale factor rounding policy.

Definition at line 3698 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ inputMethod()

QInputMethod * QGuiApplication::inputMethod ( )
static

returns the input method.

The input method returns properties about the state and position of the virtual keyboard. It also provides information about the position of the current focused input element.

See also
QInputMethod

Definition at line 4159 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ isLeftToRight()

bool QGuiApplication::isLeftToRight ( )
inlinestatic

Returns true if the application's layout direction is Qt::LeftToRight; otherwise returns false.

See also
layoutDirection(), isRightToLeft()

Definition at line 145 of file qguiapplication.h.

◆ isRightToLeft()

bool QGuiApplication::isRightToLeft ( )
inlinestatic

Returns true if the application's layout direction is Qt::RightToLeft; otherwise returns false.

See also
layoutDirection(), isLeftToRight()

Definition at line 144 of file qguiapplication.h.

Here is the caller graph for this function:

◆ isSavingSession()

bool QGuiApplication::isSavingSession ( ) const
Since
5.0

Returns true if the application is currently saving the \l{Session Management}{session}; otherwise returns false.

This is true when commitDataRequest() and saveStateRequest() are emitted, but also when the windows are closed afterwards by session management.

See also
sessionId(), commitDataRequest(), saveStateRequest()

Definition at line 3860 of file qguiapplication.cpp.

◆ isSessionRestored()

bool QGuiApplication::isSessionRestored ( ) const

Returns true if the application has been restored from an earlier \l{Session Management}{session}; otherwise returns false.

See also
sessionId(), commitDataRequest(), saveStateRequest()

Definition at line 3842 of file qguiapplication.cpp.

◆ keyboardModifiers()

Qt::KeyboardModifiers QGuiApplication::keyboardModifiers ( )
static

Returns the current state of the modifier keys on the keyboard. The current state is updated synchronously as the event queue is emptied of events that will spontaneously change the keyboard state (QEvent::KeyPress and QEvent::KeyRelease events).

It should be noted this may not reflect the actual keys held on the input device at the time of calling but rather the modifiers as last reported in one of the above events. If no keys are being held Qt::NoModifier is returned.

See also
mouseButtons(), queryKeyboardModifiers()

Definition at line 1787 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ lastWindowClosed

void QGuiApplication::lastWindowClosed ( )
signal

This signal is emitted from exec() when the last visible \l{Primary and Secondary Windows}{primary window} (i.e. top level window with no transient parent) is closed.

By default, QGuiApplication quits after this signal is emitted. This feature can be turned off by setting \l quitOnLastWindowClosed to false.

See also
QWindow::close(), QWindow::isTopLevel(), QWindow::transientParent()
Here is the caller graph for this function:

◆ layoutDirection()

static Qt::LayoutDirection QGuiApplication::layoutDirection ( )
static

◆ layoutDirectionChanged

void QGuiApplication::layoutDirectionChanged ( Qt::LayoutDirection  direction)
signal

◆ modalWindow()

QWindow * QGuiApplication::modalWindow ( )
static

Returns the most recently shown modal window. If no modal windows are visible, this function returns zero.

A modal window is a window which has its \l{QWindow::modality}{modality} property set to Qt::WindowModal or Qt::ApplicationModal. A modal window must be closed before the user can continue with other parts of the program.

Modal window are organized in a stack. This function returns the modal window at the top of the stack.

See also
Qt::WindowModality, QWindow::setModality()

Definition at line 810 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseButtons()

Qt::MouseButtons QGuiApplication::mouseButtons ( )
static

Returns the current state of the buttons on the mouse. The current state is updated synchronously as the event queue is emptied of events that will spontaneously change the mouse state (QEvent::MouseButtonPress and QEvent::MouseButtonRelease events).

It should be noted this may not reflect the actual buttons held on the input device at the time of calling but rather the mouse buttons as last reported in one of the above events. If no mouse buttons are being held Qt::NoButton is returned.

See also
keyboardModifiers()

Definition at line 1828 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ notify()

bool QGuiApplication::notify ( QObject object,
QEvent event 
)
overridevirtual

\reimp

Reimplemented from QCoreApplication.

Reimplemented in QApplication.

Definition at line 1946 of file qguiapplication.cpp.

Here is the call graph for this function:

◆ overrideCursor()

QCursor * QGuiApplication::overrideCursor ( )
static

Returns the active application override cursor.

This function returns \nullptr if no application cursor has been defined (i.e. the internal cursor stack is empty).

See also
setOverrideCursor(), restoreOverrideCursor()

Definition at line 3960 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ palette()

QPalette QGuiApplication::palette ( )
static

Returns the current application palette.

Roles that have not been explicitly set will reflect the system's platform theme.

See also
setPalette()

Definition at line 3341 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ platformFunction()

QFunctionPointer QGuiApplication::platformFunction ( const QByteArray function)
static

Definition at line 1848 of file qguiapplication.cpp.

Here is the call graph for this function:

◆ platformName()

static QString QGuiApplication::platformName ( )
static

◆ platformNativeInterface()

QGuiApplication::platformNativeInterface ( )
static

Definition at line 1838 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ primaryScreen()

static QScreen* QGuiApplication::primaryScreen ( )
static

◆ primaryScreenChanged

void QGuiApplication::primaryScreenChanged ( QScreen screen)
signal
Here is the caller graph for this function:

◆ queryKeyboardModifiers()

Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers ( )
static

Queries and returns the state of the modifier keys on the keyboard. Unlike keyboardModifiers, this method returns the actual keys held on the input device at the time of calling the method.

It does not rely on the keypress events having been received by this process, which makes it possible to check the modifiers while moving a window, for instance. Note that in most cases, you should use keyboardModifiers(), which is faster and more accurate since it contains the state of the modifiers as they were when the currently processed event was received.

See also
keyboardModifiers()

Definition at line 1808 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ quitOnLastWindowClosed()

static bool QGuiApplication::quitOnLastWindowClosed ( )
static

◆ restoreOverrideCursor()

void QGuiApplication::restoreOverrideCursor ( )
static

Undoes the last setOverrideCursor().

If setOverrideCursor() has been called twice, calling restoreOverrideCursor() will activate the first cursor set. Calling this function a second time restores the original widgets' cursors.

See also
setOverrideCursor(), overrideCursor()

Definition at line 4086 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveStateRequest

void QGuiApplication::saveStateRequest ( QSessionManager manager)
signal
Since
4.2

This signal deals with \l{Session Management}{session management}. It is invoked when the \l{QSessionManager}{session manager} wants the application to preserve its state for a future session.

For example, a text editor would create a temporary file that includes the current contents of its edit buffers, the location of the cursor and other aspects of the current editing session.

You should never exit the application within this signal. Instead, the session manager may or may not do this afterwards, depending on the context. Furthermore, most session managers will very likely request a saved state immediately after the application has been started. This permits the session manager to learn about the application's restart policy.

Warning
Within this signal, no user interaction is possible, unless you ask the manager for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details.
Note
You should use Qt::DirectConnection when connecting to this signal.
See also
isSessionRestored(), sessionId(), commitDataRequest(), {Session Management}

◆ screenAdded

void QGuiApplication::screenAdded ( QScreen screen)
signal

This signal is emitted whenever a new screen screen has been added to the system.

See also
screens(), primaryScreen, screenRemoved()
Here is the caller graph for this function:

◆ screenAt()

QScreen * QGuiApplication::screenAt ( const QPoint point)
static

Returns the screen at point, or \nullptr if outside of any screen.

The point is in relation to the virtualGeometry() of each set of virtual siblings. If the point maps to more than one set of virtual siblings the first match is returned. If you wish to search only the virtual desktop siblings of a known screen (for example siblings of the screen of your application window QWidget::windowHandle()->screen()), use QScreen::virtualSiblingAt().

Since
5.10

Definition at line 1063 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ screenRemoved

void QGuiApplication::screenRemoved ( QScreen screen)
signal

This signal is emitted whenever a screen is removed from the system. It provides an opportunity to manage the windows on the screen before Qt falls back to moving them to the primary screen.

See also
screens(), screenAdded(), QObject::destroyed(), QWindow::setScreen()
Since
5.4
Here is the caller graph for this function:

◆ screens()

QList< QScreen * > QGuiApplication::screens ( )
static

Returns a list of all the screens associated with the windowing system the application is connected to.

Definition at line 1047 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ sessionId()

QString QGuiApplication::sessionId ( ) const

Returns the current \l{Session Management}{session's} identifier.

If the application has been restored from an earlier session, this identifier is the same as it was in that previous session. The session identifier is guaranteed to be unique both for different applications and for different instances of the same application.

See also
isSessionRestored(), sessionKey(), commitDataRequest(), saveStateRequest()

Definition at line 3848 of file qguiapplication.cpp.

◆ sessionKey()

QString QGuiApplication::sessionKey ( ) const

Returns the session key in the current \l{Session Management}{session}.

If the application has been restored from an earlier session, this key is the same as it was when the previous session ended.

The session key changes every time the session is saved. If the shutdown process is cancelled, another session key will be used when shutting down again.

See also
isSessionRestored(), sessionId(), commitDataRequest(), saveStateRequest()

Definition at line 3854 of file qguiapplication.cpp.

◆ setApplicationDisplayName()

void QGuiApplication::setApplicationDisplayName ( const QString name)
static

Definition at line 745 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDesktopFileName()

void QGuiApplication::setDesktopFileName ( const QString name)
static

Definition at line 784 of file qguiapplication.cpp.

◆ setDesktopSettingsAware()

void QGuiApplication::setDesktopSettingsAware ( bool  on)
static

Sets whether Qt should use the system's standard colors, fonts, etc., to on. By default, this is true.

This function must be called before creating the QGuiApplication object, like this:

See also
desktopSettingsAware()

Definition at line 4134 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ setFont()

void QGuiApplication::setFont ( const QFont font)
static

Changes the default application font to font.

See also
font()

Definition at line 3465 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setHighDpiScaleFactorRoundingPolicy()

void QGuiApplication::setHighDpiScaleFactorRoundingPolicy ( Qt::HighDpiScaleFactorRoundingPolicy  policy)
static
Since
5.14

Sets the high-DPI scale factor rounding policy for the application. The policy decides how non-integer scale factors (such as Windows 150%) are handled.

The two principal options are whether fractional scale factors should be rounded to an integer or not. Keeping the scale factor as-is will make the user interface size match the OS setting exactly, but may cause painting errors, for example with the Windows style.

If rounding is wanted, then which type of rounding should be decided next. Mathematically correct rounding is supported but may not give the best visual results: Consider if you want to render 1.5x as 1x ("small UI") or as 2x ("large UI"). See the Qt::HighDpiScaleFactorRoundingPolicy enum for a complete list of all options.

This function must be called before creating the application object. The QGuiApplication::highDpiScaleFactorRoundingPolicy() accessor will reflect the environment, if set.

The default value is Qt::HighDpiScaleFactorRoundingPolicy::PassThrough.

Definition at line 3688 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ setLayoutDirection()

void QGuiApplication::setLayoutDirection ( Qt::LayoutDirection  direction)
static

Definition at line 3919 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ setOverrideCursor()

void QGuiApplication::setOverrideCursor ( const QCursor cursor)
static

Sets the application override cursor to cursor.

Application override cursors are intended for showing the user that the application is in a special state, for example during an operation that might take some time.

This cursor will be displayed in all the application's widgets until restoreOverrideCursor() or another setOverrideCursor() is called.

Application cursors are stored on an internal stack. setOverrideCursor() pushes the cursor onto the stack, and restoreOverrideCursor() pops the active cursor off the stack. changeOverrideCursor() changes the currently active application override cursor.

Every setOverrideCursor() must eventually be followed by a corresponding restoreOverrideCursor(), otherwise the stack will never be emptied.

Example:

See also
overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(), QWidget::setCursor()

Definition at line 4065 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPalette()

void QGuiApplication::setPalette ( const QPalette pal)
static

Changes the application palette to pal.

The color roles from this palette are combined with the system's platform theme to form the application's final palette.

See also
palette()

Definition at line 3373 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setQuitOnLastWindowClosed()

void QGuiApplication::setQuitOnLastWindowClosed ( bool  quit)
static

Definition at line 3575 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setWindowIcon()

void QGuiApplication::setWindowIcon ( const QIcon icon)
static

Definition at line 3538 of file qguiapplication.cpp.

Here is the call graph for this function:

◆ styleHints()

QStyleHints * QGuiApplication::styleHints ( )
static

Returns the application's style hints.

The style hints encapsulate a set of platform dependent properties such as double click intervals, full width selection and others.

The hints can be used to integrate tighter with the underlying platform.

See also
QStyleHints

Definition at line 4116 of file qguiapplication.cpp.

Here is the caller graph for this function:

◆ sync()

void QGuiApplication::sync ( )
static
Since
5.2

Function that can be used to sync Qt state with the Window Systems state.

This function will first empty Qts events by calling QCoreApplication::processEvents(), then the platform plugin will sync up with the windowsystem, and finally Qts events will be delived by another call to QCoreApplication::processEvents();

This function is timeconsuming and its use is discouraged.

Definition at line 3895 of file qguiapplication.cpp.

Here is the call graph for this function:

◆ topLevelAt()

QWindow * QGuiApplication::topLevelAt ( const QPoint pos)
static

Returns the top level window at the given position pos, if any.

Definition at line 1145 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ topLevelWindows()

QWindowList QGuiApplication::topLevelWindows ( )
static

Returns a list of the top-level windows in the application.

See also
allWindows()

Definition at line 1010 of file qguiapplication.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ windowIcon()

static QIcon QGuiApplication::windowIcon ( )
static

Friends And Related Function Documentation

◆ QFontDatabasePrivate

friend class QFontDatabasePrivate
friend

Definition at line 213 of file qguiapplication.h.

◆ QPlatformIntegration

friend class QPlatformIntegration
friend

Definition at line 214 of file qguiapplication.h.

◆ QPlatformSessionManager

friend class QPlatformSessionManager
friend

Definition at line 216 of file qguiapplication.h.

Property Documentation

◆ applicationDisplayName

QString QGuiApplication::applicationDisplayName
readwrite

the user-visible name of this application

Since
5.0

This name is shown to the user, for instance in window titles. It can be translated, if necessary.

If not set, the application display name defaults to the application name.

See also
applicationName

Definition at line 220 of file qguiapplication.h.

◆ desktopFileName

QString QGuiApplication::desktopFileName
readwrite

the base name of the desktop entry for this application

Since
5.7

This is the file name, without the full path, of the desktop entry that represents this application according to the freedesktop desktop entry specification.

This property gives a precise indication of what desktop entry represents the application and it is needed by the windowing system to retrieve such information without resorting to imprecise heuristics.

The latest version of the freedesktop desktop entry specification can be obtained \l{http://standards.freedesktop.org/desktop-entry-spec/latest/}{here}.

Definition at line 220 of file qguiapplication.h.

◆ layoutDirection

Qt::LayoutDirection QGuiApplication::layoutDirection
readwrite

the default layout direction for this application

On system start-up, or when the direction is explicitly set to Qt::LayoutDirectionAuto, the default layout direction depends on the application's language.

The notifier signal was introduced in Qt 5.4.

See also
QWidget::layoutDirection, isLeftToRight(), isRightToLeft()

Definition at line 220 of file qguiapplication.h.

◆ platformName

QString QGuiApplication::platformName
read

The name of the underlying platform plugin.

The QPA platform plugins are located in {qtbase\src \plugins\platforms}. At the time of writing, the following platform plugin names are supported:

\list

  • android
  • cocoa is a platform plugin for \macos.
  • directfb
  • eglfs is a platform plugin for running Qt5 applications on top of EGL and OpenGL ES 2.0 without an actual windowing system (like X11 or Wayland). For more information, see \l{EGLFS}.
  • ios (also used for tvOS)
  • linuxfb writes directly to the framebuffer. For more information, see \l{LinuxFB}.
  • minimal is provided as an examples for developers who want to write their own platform plugins. However, you can use the plugin to run GUI applications in environments without a GUI, such as servers.
  • minimalegl is an example plugin.
  • offscreen
  • qnx
  • windows
  • wayland is a platform plugin for modern Linux desktops and some embedded systems.
  • xcb is the X11 plugin used on regular desktop Linux platforms. \endlist

For more information about the platform plugins for embedded Linux devices, see \l{Qt for Embedded Linux}.

Definition at line 220 of file qguiapplication.h.

◆ primaryScreen

QGuiApplication::primaryScreen
read

the primary (or default) screen of the application.

This will be the screen where QWindows are initially shown, unless otherwise specified.

The primaryScreenChanged signal was introduced in Qt 5.6.

See also
screens()

Definition at line 220 of file qguiapplication.h.

◆ quitOnLastWindowClosed

bool QGuiApplication::quitOnLastWindowClosed
readwrite

whether the application implicitly quits when the last window is closed.

The default is true.

If this property is true, the applications quits when the last visible \l{Primary and Secondary Windows}{primary window} (i.e. top level window with no transient parent) is closed.

See also
quit(), QWindow::close()

Definition at line 220 of file qguiapplication.h.

◆ windowIcon

QIcon QGuiApplication::windowIcon
readwrite

the default window icon

See also
QWindow::setIcon(), {Setting the Application Icon}

Definition at line 220 of file qguiapplication.h.


The documentation for this class was generated from the following files: