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
qquickwindow.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 QQUICKWINDOW_H
6#define QQUICKWINDOW_H
7
8#include <QtQuick/qtquickglobal.h>
9#include <QtQuick/qsgrendererinterface.h>
10
11#include <QtCore/qmetatype.h>
12#include <QtGui/qwindow.h>
13#include <QtGui/qevent.h>
14#include <QtQml/qqml.h>
15#include <QtQml/qqmldebug.h>
16#include <QtQml/qqmlinfo.h>
17
18QT_BEGIN_NAMESPACE
19
20class QRunnable;
21class QQuickItem;
22class QSGTexture;
23class QInputMethodEvent;
24class QQuickWindowPrivate;
25class QQuickWindowAttached;
26class QQmlIncubationController;
27class QInputMethodEvent;
28class QQuickCloseEvent;
29class QQuickRenderControl;
30class QSGRectangleNode;
31class QSGImageNode;
32class QSGNinePatchNode;
33class QQuickPalette;
34class QQuickRenderTarget;
35class QQuickGraphicsDevice;
36class QQuickGraphicsConfiguration;
37class QRhi;
38class QRhiSwapChain;
39class QRhiTexture;
40class QSGTextNode;
41
42class Q_QUICK_EXPORT QQuickWindow : public QWindow
43{
44 Q_OBJECT
45 Q_PRIVATE_PROPERTY(QQuickWindow::d_func(), QQmlListProperty<QObject> data READ data DESIGNABLE false)
46 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
47 Q_PROPERTY(QQuickItem* contentItem READ contentItem CONSTANT)
48 Q_PROPERTY(QQuickItem* activeFocusItem READ activeFocusItem NOTIFY activeFocusItemChanged REVISION(2, 1))
49 Q_PRIVATE_PROPERTY(QQuickWindow::d_func(), QQuickPalette *palette READ palette WRITE setPalette
50 RESET resetPalette NOTIFY paletteChanged REVISION(6, 2))
51 QDOC_PROPERTY(QWindow* transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged)
52 Q_CLASSINFO("DefaultProperty", "data")
53 Q_DECLARE_PRIVATE(QQuickWindow)
54
55 QML_NAMED_ELEMENT(Window)
56 QML_ADDED_IN_VERSION(2, 0)
57 QML_REMOVED_IN_VERSION(2, 1)
58public:
59 enum CreateTextureOption {
60 TextureHasAlphaChannel = 0x0001,
61 TextureHasMipmaps = 0x0002,
62 TextureOwnsGLTexture = 0x0004,
63 TextureCanUseAtlas = 0x0008,
64 TextureIsOpaque = 0x0010
65 };
66
67 enum RenderStage {
68 BeforeSynchronizingStage,
69 AfterSynchronizingStage,
70 BeforeRenderingStage,
71 AfterRenderingStage,
72 AfterSwapStage,
73 NoStage
74 };
75
76 Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)
77 Q_FLAG(CreateTextureOptions)
78
79 enum SceneGraphError {
80 ContextNotAvailable = 1
81 };
82 Q_ENUM(SceneGraphError)
83
84 enum TextRenderType {
85 QtTextRendering,
86 NativeTextRendering,
87 CurveTextRendering
88 };
89 Q_ENUM(TextRenderType)
90
91 explicit QQuickWindow(QWindow *parent = nullptr);
92 explicit QQuickWindow(QQuickRenderControl *renderControl);
93
94 ~QQuickWindow() override;
95
96 QQuickItem *contentItem() const;
97
98 QQuickItem *activeFocusItem() const;
99 QObject *focusObject() const override;
100
101 QQuickItem *mouseGrabberItem() const;
102
103 QImage grabWindow();
104
105 void setRenderTarget(const QQuickRenderTarget &target);
106 QQuickRenderTarget renderTarget() const;
107
108 struct GraphicsStateInfo {
109 int currentFrameSlot;
110 int framesInFlight;
111 };
112 const GraphicsStateInfo &graphicsStateInfo();
113 void beginExternalCommands();
114 void endExternalCommands();
115 QQmlIncubationController *incubationController() const;
116
117#if QT_CONFIG(accessibility)
118 QAccessibleInterface *accessibleRoot() const override;
119#endif
120
121 // Scene graph specific functions
122 QSGTexture *createTextureFromImage(const QImage &image) const;
123 QSGTexture *createTextureFromImage(const QImage &image, CreateTextureOptions options) const;
124 QSGTexture *createTextureFromRhiTexture(QRhiTexture *texture, CreateTextureOptions options = {}) const;
125
126 void setColor(const QColor &color);
127 QColor color() const;
128
129 static bool hasDefaultAlphaBuffer();
130 static void setDefaultAlphaBuffer(bool useAlpha);
131
132 void setPersistentGraphics(bool persistent);
133 bool isPersistentGraphics() const;
134
135 void setPersistentSceneGraph(bool persistent);
136 bool isPersistentSceneGraph() const;
137
138 bool isSceneGraphInitialized() const;
139
140 void scheduleRenderJob(QRunnable *job, RenderStage schedule);
141
142 qreal effectiveDevicePixelRatio() const;
143
144 QSGRendererInterface *rendererInterface() const;
145
146 static void setGraphicsApi(QSGRendererInterface::GraphicsApi api);
147 static QSGRendererInterface::GraphicsApi graphicsApi();
148
149 static void setSceneGraphBackend(const QString &backend);
150 static QString sceneGraphBackend();
151
152 void setGraphicsDevice(const QQuickGraphicsDevice &device);
153 QQuickGraphicsDevice graphicsDevice() const;
154
155 void setGraphicsConfiguration(const QQuickGraphicsConfiguration &config);
156 QQuickGraphicsConfiguration graphicsConfiguration() const;
157
158 QSGRectangleNode *createRectangleNode() const;
159 QSGImageNode *createImageNode() const;
160 QSGNinePatchNode *createNinePatchNode() const;
161 QSGTextNode *createTextNode() const;
162
163 static TextRenderType textRenderType();
164 static void setTextRenderType(TextRenderType renderType);
165
166 QRhi *rhi() const;
167 QRhiSwapChain *swapChain() const;
168
169Q_SIGNALS:
170 void frameSwapped();
171 void sceneGraphInitialized();
172 void sceneGraphInvalidated();
173 void beforeSynchronizing();
174 Q_REVISION(2, 2) void afterSynchronizing();
175 void beforeRendering();
176 void afterRendering();
177 Q_REVISION(2, 2) void afterAnimating();
178 Q_REVISION(2, 2) void sceneGraphAboutToStop();
179
180 Q_REVISION(2, 1) void closing(QQuickCloseEvent *close);
181 void colorChanged(const QColor &);
182 Q_REVISION(2, 1) void activeFocusItemChanged();
183 Q_REVISION(2, 2) void sceneGraphError(QQuickWindow::SceneGraphError error, const QString &message);
184
185 Q_REVISION(2, 14) void beforeRenderPassRecording();
186 Q_REVISION(2, 14) void afterRenderPassRecording();
187
188 Q_REVISION(6, 0) void paletteChanged();
189 Q_REVISION(6, 0) void paletteCreated();
190
191 Q_REVISION(6, 0) void beforeFrameBegin();
192 Q_REVISION(6, 0) void afterFrameEnd();
193
194public Q_SLOTS:
195 void update();
196 void releaseResources();
197
198protected:
199 QQuickWindow(QQuickWindowPrivate &dd, QWindow *parent = nullptr);
200 QQuickWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
201
202 void exposeEvent(QExposeEvent *) override;
203 void resizeEvent(QResizeEvent *) override;
204
205 void showEvent(QShowEvent *) override;
206 void hideEvent(QHideEvent *) override;
207 void closeEvent(QCloseEvent *) override;
208
209 void focusInEvent(QFocusEvent *) override;
210 void focusOutEvent(QFocusEvent *) override;
211
212 bool event(QEvent *) override;
213
214 // These overrides are no longer normal entry points for
215 // input events, but kept in case legacy code calls them.
216 void keyPressEvent(QKeyEvent *) override;
217 void keyReleaseEvent(QKeyEvent *) override;
218 void mousePressEvent(QMouseEvent *) override;
219 void mouseReleaseEvent(QMouseEvent *) override;
220 void mouseDoubleClickEvent(QMouseEvent *) override;
221 void mouseMoveEvent(QMouseEvent *) override;
222#if QT_CONFIG(wheelevent)
223 void wheelEvent(QWheelEvent *) override;
224#endif
225#if QT_CONFIG(tabletevent)
226 void tabletEvent(QTabletEvent *) override;
227#endif
228
229private Q_SLOTS:
230 void maybeUpdate();
231 void cleanupSceneGraph();
232 void physicalDpiChanged();
233 void handleScreenChanged(QScreen *screen);
234 void runJobsAfterSwap();
235 void handleApplicationStateChanged(Qt::ApplicationState state);
236 void handleFontDatabaseChanged();
237private:
238#ifndef QT_NO_DEBUG_STREAM
239 inline friend QQmlInfo operator<<(QQmlInfo info, const QQuickWindow *window)
240 {
241 info.QDebug::operator<<(window);
242 return info;
243 }
244#endif
245
246 friend class QQuickItem;
247 friend class QQuickItemPrivate;
248 friend class QQuickWidget;
249 friend class QQuickRenderControl;
250 friend class QQuickAnimatorController;
251 friend class QQuickWidgetPrivate;
252 friend class QQuickDeliveryAgentPrivate;
253 Q_DISABLE_COPY(QQuickWindow)
254};
255
256#ifndef QT_NO_DEBUG_STREAM
257QDebug Q_QUICK_EXPORT operator<<(QDebug debug, const QQuickWindow *item);
258
259inline QQmlInfo operator<<(QQmlInfo info, const QWindow *window)
260{
261 info.QDebug::operator<<(window);
262 return info;
263}
264#endif
265
266QT_END_NAMESPACE
267
268Q_DECLARE_METATYPE(QQuickWindow *)
269
270#endif // QQUICKWINDOW_H
bool contains(const QPointF &point) const override
bool startTransition(QQuickFlickablePrivate::AxisData *data, qreal toPos)
QQuickFlickableReboundTransition(QQuickFlickable *f, const QString &name)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
\qmltype Window \nativetype QQuickWindow \inqmlmodule QtQuick
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
QDebug operator<<(QDebug dbg, const NSObject *nsObject)
Definition qcore_mac.mm:201
static bool fuzzyLessThanOrEqualTo(qreal a, qreal b)
static qreal EaseOvershoot(qreal t)
const qreal _q_MaximumWheelDeceleration
#define QML_FLICK_SAMPLEBUFFER
#define QML_FLICK_OVERSHOOT
#define QML_FLICK_MULTIFLICK_MAXBOOST
#define QML_FLICK_MULTIFLICK_THRESHOLD
#define QML_FLICK_OVERSHOOTFRICTION
#define QML_FLICK_DISCARDSAMPLES
#define QML_FLICK_MULTIFLICK_RATIO
QDebug Q_QUICK_EXPORT operator<<(QDebug debug, const QQuickWindow *item)