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
51public:
52#ifdef Q_QDOC
53 QGuiApplication(int &argc, char **argv);
54#else
55 QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
56#endif
57 ~QGuiApplication();
58
59 static void setApplicationDisplayName(const QString &name);
60 static QString applicationDisplayName();
61
62 Q_SLOT void setBadgeNumber(qint64 number);
63
64 static void setDesktopFileName(const QString &name);
65 static QString desktopFileName();
66
67 static QWindowList allWindows();
68 static QWindowList topLevelWindows();
69 static QWindow *topLevelAt(const QPoint &pos);
70
71 static void setWindowIcon(const QIcon &icon);
72 static QIcon windowIcon();
73
74 static QString platformName();
75
76 static QWindow *modalWindow();
77
78 static QWindow *focusWindow();
79 static QObject *focusObject();
80
81 static QScreen *primaryScreen();
82 static QList<QScreen *> screens();
83 static QScreen *screenAt(const QPoint &point);
84
85 qreal devicePixelRatio() const;
86
87#ifndef QT_NO_CURSOR
88 static QCursor *overrideCursor();
89 static void setOverrideCursor(const QCursor &);
90 static void changeOverrideCursor(const QCursor &);
91 static void restoreOverrideCursor();
92#endif
93
94 static QFont font();
95 static void setFont(const QFont &);
96
97#ifndef QT_NO_CLIPBOARD
98 static QClipboard *clipboard();
99#endif
100
101 static QPalette palette();
102 static void setPalette(const QPalette &pal);
103
104 static Qt::KeyboardModifiers keyboardModifiers();
105 static Qt::KeyboardModifiers queryKeyboardModifiers();
106 static Qt::MouseButtons mouseButtons();
107
108 static void setLayoutDirection(Qt::LayoutDirection direction);
109 static Qt::LayoutDirection layoutDirection();
110
111 static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; }
112 static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
113
114 static QStyleHints *styleHints();
115 static void setDesktopSettingsAware(bool on);
116 static bool desktopSettingsAware();
117
118 static QInputMethod *inputMethod();
119
120 static QPlatformNativeInterface *platformNativeInterface();
121
122 static QFunctionPointer platformFunction(const QByteArray &function);
123
124 static void setQuitOnLastWindowClosed(bool quit);
125 static bool quitOnLastWindowClosed();
126
127 static Qt::ApplicationState applicationState();
128
129 static void setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy);
130 static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy();
131
132 static int exec();
133 bool notify(QObject *, QEvent *) override;
134
135#ifndef QT_NO_SESSIONMANAGER
136 // session management
137 bool isSessionRestored() const;
138 QString sessionId() const;
139 QString sessionKey() const;
140 bool isSavingSession() const;
141#endif
142
143 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QGuiApplication)
145 static void sync();
146Q_SIGNALS:
147 void fontDatabaseChanged();
148 void screenAdded(QScreen *screen);
149 void screenRemoved(QScreen *screen);
150 void primaryScreenChanged(QScreen *screen);
151 void lastWindowClosed();
152 void focusObjectChanged(QObject *focusObject);
153 void focusWindowChanged(QWindow *focusWindow);
154 void applicationStateChanged(Qt::ApplicationState state);
155 void layoutDirectionChanged(Qt::LayoutDirection direction);
156#ifndef QT_NO_SESSIONMANAGER
157 void commitDataRequest(QSessionManager &sessionManager);
158 void saveStateRequest(QSessionManager &sessionManager);
159#endif
160 void applicationDisplayNameChanged();
161#if QT_DEPRECATED_SINCE(6, 0)
162 QT_DEPRECATED_VERSION_X_6_0("Handle QEvent::ApplicationPaletteChange instead") void paletteChanged(const QPalette &pal);
163 QT_DEPRECATED_VERSION_X_6_0("Handle QEvent::ApplicationFontChange instead") void fontChanged(const QFont &font);
164#endif
165protected:
166 bool event(QEvent *) override;
167# if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
168 QT_DEPRECATED_VERSION_X_6_10("This feature will be removed in Qt 7")
169 bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override;
170# endif
171
172 QGuiApplication(QGuiApplicationPrivate &p);
173
174private:
175 Q_DISABLE_COPY(QGuiApplication)
176 Q_DECLARE_PRIVATE(QGuiApplication)
177
178 Q_PRIVATE_SLOT(d_func(), void _q_updateFocusObject(QObject *object))
179 Q_PRIVATE_SLOT(d_func(), void _q_updatePrimaryScreenDpis())
180
181#ifndef QT_NO_GESTURES
182 friend class QGestureManager;
183#endif
184 friend class QFontDatabasePrivate;
185 friend class QPlatformIntegration;
186#ifndef QT_NO_SESSIONMANAGER
187 friend class QPlatformSessionManager;
188#endif
189};
190
191QT_END_NAMESPACE
192
193#include <QtGui/qguiapplication_platform.h>
194
195#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)