Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qguiapplication.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QGUIAPPLICATION_H
6#define QGUIAPPLICATION_H
7
8#include <QtGui/qtguiglobal.h>
9#include <QtCore/qcoreapplication.h>
10#include <QtGui/qwindowdefs.h>
11#include <QtGui/qinputmethod.h>
12#include <QtCore/qlocale.h>
13#include <QtCore/qpoint.h>
14#include <QtCore/qsize.h>
15
16QT_BEGIN_NAMESPACE
17
18
19class QSessionManager;
20class QGuiApplicationPrivate;
21class QPlatformNativeInterface;
22class QPlatformIntegration;
23class QPalette;
24class QScreen;
25class QStyleHints;
26
27#if defined(qApp)
28#undef qApp
29#endif
30#define qApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
31
32#if defined(qGuiApp)
33#undef qGuiApp
34#endif
35#define qGuiApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
36
37class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
38{
39 Q_OBJECT
40 Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
41 Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName
42 WRITE setApplicationDisplayName NOTIFY applicationDisplayNameChanged)
43 Q_PROPERTY(QString desktopFileName READ desktopFileName WRITE setDesktopFileName)
44 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection
45 NOTIFY layoutDirectionChanged)
46 Q_PROPERTY(QString platformName READ platformName STORED false CONSTANT)
47 Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed
48 WRITE setQuitOnLastWindowClosed)
49 Q_PROPERTY(QScreen *primaryScreen READ primaryScreen NOTIFY primaryScreenChanged STORED false)
50 Q_PROPERTY(qint64 badgeNumber READ badgeNumber WRITE setBadgeNumber
51 NOTIFY badgeNumberChanged REVISION(6, 13))
52
53public:
54#ifdef Q_QDOC
55 QGuiApplication(int &argc, char **argv);
56#else
57 QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
58#endif
59 ~QGuiApplication();
60
61 static void setApplicationDisplayName(const QString &name);
62 static QString applicationDisplayName();
63
64 qint64 badgeNumber() const;
65 Q_SLOT void setBadgeNumber(qint64 number);
66
67 static void setDesktopFileName(const QString &name);
68 static QString desktopFileName();
69
70 static QWindowList allWindows();
71 static QWindowList topLevelWindows();
72 static QWindow *topLevelAt(const QPoint &pos);
74 static void setWindowIcon(const QIcon &icon);
75 static QIcon windowIcon();
76
77 static QString platformName();
78
79 static QWindow *modalWindow();
81 static QWindow *focusWindow();
82 static QObject *focusObject();
83
84 static QScreen *primaryScreen();
85 static QList<QScreen *> screens();
86 static QScreen *screenAt(const QPoint &point);
87
88 qreal devicePixelRatio() const;
89
90#ifndef QT_NO_CURSOR
91 static QCursor *overrideCursor();
92 static void setOverrideCursor(const QCursor &);
93 static void changeOverrideCursor(const QCursor &);
94 static void restoreOverrideCursor();
95#endif
96
97 static QFont font();
98 static void setFont(const QFont &);
99
100#ifndef QT_NO_CLIPBOARD
101 static QClipboard *clipboard();
102#endif
103
104 static QPalette palette();
105 static void setPalette(const QPalette &pal);
106
107 static Qt::KeyboardModifiers keyboardModifiers();
108 static Qt::KeyboardModifiers queryKeyboardModifiers();
109 static Qt::MouseButtons mouseButtons();
111 static void setLayoutDirection(Qt::LayoutDirection direction);
112 static Qt::LayoutDirection layoutDirection();
113
114 static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; }
115 static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
116
117 static QStyleHints *styleHints();
118 static void setDesktopSettingsAware(bool on);
119 static bool desktopSettingsAware();
120
121 static QInputMethod *inputMethod();
122
123 static QPlatformNativeInterface *platformNativeInterface();
125 static QFunctionPointer platformFunction(const QByteArray &function);
126
127 static void setQuitOnLastWindowClosed(bool quit);
128 static bool quitOnLastWindowClosed();
129
130 static Qt::ApplicationState applicationState();
131
132 static void setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy);
133 static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy();
134
135 static int exec();
136 bool notify(QObject *, QEvent *) override;
137
138#ifndef QT_NO_SESSIONMANAGER
139 // session management
140 bool isSessionRestored() const;
141 QString sessionId() const;
142 QString sessionKey() const;
143 bool isSavingSession() const;
144#endif
145
146 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QGuiApplication)
148 static void sync();
149Q_SIGNALS:
150 void fontDatabaseChanged();
151 void screenAdded(QScreen *screen);
152 void screenRemoved(QScreen *screen);
153 void primaryScreenChanged(QScreen *screen);
154 void lastWindowClosed();
155 void focusObjectChanged(QObject *focusObject);
156 void focusWindowChanged(QWindow *focusWindow);
157 void applicationStateChanged(Qt::ApplicationState state);
158 void layoutDirectionChanged(Qt::LayoutDirection direction);
159#ifndef QT_NO_SESSIONMANAGER
160 void commitDataRequest(QSessionManager &sessionManager);
161 void saveStateRequest(QSessionManager &sessionManager);
162#endif
163 void applicationDisplayNameChanged();
164 void badgeNumberChanged(qint64 number);
165#if QT_DEPRECATED_SINCE(6, 0)
166 QT_DEPRECATED_VERSION_X_6_0("Handle QEvent::ApplicationPaletteChange instead") void paletteChanged(const QPalette &pal);
167 QT_DEPRECATED_VERSION_X_6_0("Handle QEvent::ApplicationFontChange instead") void fontChanged(const QFont &font);
168#endif
169protected:
170 bool event(QEvent *) override;
171# if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
172 QT_DEPRECATED_VERSION_X_6_10("This feature will be removed in Qt 7")
173 bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override;
174# endif
175
176 QGuiApplication(QGuiApplicationPrivate &p);
177
178private:
179 Q_DISABLE_COPY(QGuiApplication)
180 Q_DECLARE_PRIVATE(QGuiApplication)
181
182 Q_PRIVATE_SLOT(d_func(), void _q_updateFocusObject(QObject *object))
183 Q_PRIVATE_SLOT(d_func(), void _q_updatePrimaryScreenDpis())
185#ifndef QT_NO_GESTURES
186 friend class QGestureManager;
187#endif
188 friend class QFontDatabasePrivate;
189 friend class QPlatformIntegration;
190#ifndef QT_NO_SESSIONMANAGER
191 friend class QPlatformSessionManager;
192#endif
193};
194
195QT_END_NAMESPACE
196
197#include <QtGui/qguiapplication_platform.h>
198
199#endif // QGUIAPPLICATION_H
\macro qGuiApp
Combined button and popup list for selecting options.
static QPlatformTheme::IconOptions toThemeIconOptions(QAbstractFileIconProvider::Options options)
Q_GLOBAL_STATIC(QReadWriteLock, g_updateMutex)