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_PROPERTY(qreal devicePixelRatio READ effectiveDevicePixelRatio NOTIFY devicePixelRatioChanged REVISION(6, 11))
53 Q_CLASSINFO("DefaultProperty", "data")
54 Q_DECLARE_PRIVATE(QQuickWindow)
55
56 QML_NAMED_ELEMENT(Window)
57 QML_ADDED_IN_VERSION(2, 0)
58 QML_REMOVED_IN_VERSION(2, 1)
59public:
60 enum CreateTextureOption {
61 TextureHasAlphaChannel = 0x0001,
62 TextureHasMipmaps = 0x0002,
63 TextureOwnsGLTexture = 0x0004,
64 TextureCanUseAtlas = 0x0008,
65 TextureIsOpaque = 0x0010
66 };
67
68 enum RenderStage {
69 BeforeSynchronizingStage,
70 AfterSynchronizingStage,
71 BeforeRenderingStage,
72 AfterRenderingStage,
73 AfterSwapStage,
74 NoStage
75 };
76
77 Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)
78 Q_FLAG(CreateTextureOptions)
79
80 enum SceneGraphError {
81 ContextNotAvailable = 1
82 };
83 Q_ENUM(SceneGraphError)
84
85 enum TextRenderType {
86 QtTextRendering,
87 NativeTextRendering,
88 CurveTextRendering
89 };
90 Q_ENUM(TextRenderType)
91
92 explicit QQuickWindow(QWindow *parent = nullptr);
93 explicit QQuickWindow(QQuickRenderControl *renderControl);
94
95 ~QQuickWindow() override;
96
97 QQuickItem *contentItem() const;
98
99 QQuickItem *activeFocusItem() const;
100 QObject *focusObject() const override;
101
102 QQuickItem *mouseGrabberItem() const;
103
104 QImage grabWindow();
105
106 void setRenderTarget(const QQuickRenderTarget &target);
107 QQuickRenderTarget renderTarget() const;
108
109 struct GraphicsStateInfo {
110 int currentFrameSlot;
111 int framesInFlight;
112 };
113 const GraphicsStateInfo &graphicsStateInfo();
114 void beginExternalCommands();
115 void endExternalCommands();
116 QQmlIncubationController *incubationController() const;
117
118#if QT_CONFIG(accessibility)
119 QAccessibleInterface *accessibleRoot() const override;
120#endif
121
122 // Scene graph specific functions
123 QSGTexture *createTextureFromImage(const QImage &image) const;
124 QSGTexture *createTextureFromImage(const QImage &image, CreateTextureOptions options) const;
125 QSGTexture *createTextureFromRhiTexture(QRhiTexture *texture, CreateTextureOptions options = {}) const;
126
127 void setColor(const QColor &color);
128 QColor color() const;
129
130 static bool hasDefaultAlphaBuffer();
131 static void setDefaultAlphaBuffer(bool useAlpha);
132
133 void setPersistentGraphics(bool persistent);
134 bool isPersistentGraphics() const;
135
136 void setPersistentSceneGraph(bool persistent);
137 bool isPersistentSceneGraph() const;
138
139 bool isSceneGraphInitialized() const;
140
141 void scheduleRenderJob(QRunnable *job, RenderStage schedule);
142
143 qreal effectiveDevicePixelRatio() const;
144
145 QSGRendererInterface *rendererInterface() const;
146
147 static void setGraphicsApi(QSGRendererInterface::GraphicsApi api);
148 static QSGRendererInterface::GraphicsApi graphicsApi();
149
150 static void setSceneGraphBackend(const QString &backend);
151 static QString sceneGraphBackend();
152
153 void setGraphicsDevice(const QQuickGraphicsDevice &device);
154 QQuickGraphicsDevice graphicsDevice() const;
155
156 void setGraphicsConfiguration(const QQuickGraphicsConfiguration &config);
157 QQuickGraphicsConfiguration graphicsConfiguration() const;
158
159 QSGRectangleNode *createRectangleNode() const;
160 QSGImageNode *createImageNode() const;
161 QSGNinePatchNode *createNinePatchNode() const;
162 QSGTextNode *createTextNode() const;
163
164 static TextRenderType textRenderType();
165 static void setTextRenderType(TextRenderType renderType);
166
167 QRhi *rhi() const;
168 QRhiSwapChain *swapChain() const;
169
170Q_SIGNALS:
171 void frameSwapped();
172 void sceneGraphInitialized();
173 void sceneGraphInvalidated();
174 void beforeSynchronizing();
175 Q_REVISION(2, 2) void afterSynchronizing();
176 void beforeRendering();
177 void afterRendering();
178 Q_REVISION(2, 2) void afterAnimating();
179 Q_REVISION(2, 2) void sceneGraphAboutToStop();
180
181 Q_REVISION(2, 1) void closing(QQuickCloseEvent *close);
182 void colorChanged(const QColor &);
183 Q_REVISION(2, 1) void activeFocusItemChanged();
184 Q_REVISION(2, 2) void sceneGraphError(QQuickWindow::SceneGraphError error, const QString &message);
185
186 Q_REVISION(2, 14) void beforeRenderPassRecording();
187 Q_REVISION(2, 14) void afterRenderPassRecording();
188
189 Q_REVISION(6, 0) void paletteChanged();
190 Q_REVISION(6, 0) void paletteCreated();
191
192 Q_REVISION(6, 0) void beforeFrameBegin();
193 Q_REVISION(6, 0) void afterFrameEnd();
194
195 Q_REVISION(6, 11) void devicePixelRatioChanged();
196
197public Q_SLOTS:
198 void update();
199 void releaseResources();
200
201protected:
202 QQuickWindow(QQuickWindowPrivate &dd, QWindow *parent = nullptr);
203 QQuickWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
204
205 void exposeEvent(QExposeEvent *) override;
206 void resizeEvent(QResizeEvent *) override;
207
208 void showEvent(QShowEvent *) override;
209 void hideEvent(QHideEvent *) override;
210 void closeEvent(QCloseEvent *) override;
211
212 void focusInEvent(QFocusEvent *) override;
213 void focusOutEvent(QFocusEvent *) override;
214
215 bool event(QEvent *) override;
216
217 // These overrides are no longer normal entry points for
218 // input events, but kept in case legacy code calls them.
219 void keyPressEvent(QKeyEvent *) override;
220 void keyReleaseEvent(QKeyEvent *) override;
221 void mousePressEvent(QMouseEvent *) override;
222 void mouseReleaseEvent(QMouseEvent *) override;
223 void mouseDoubleClickEvent(QMouseEvent *) override;
224 void mouseMoveEvent(QMouseEvent *) override;
225#if QT_CONFIG(wheelevent)
226 void wheelEvent(QWheelEvent *) override;
227#endif
228#if QT_CONFIG(tabletevent)
229 void tabletEvent(QTabletEvent *) override;
230#endif
231
232private Q_SLOTS:
233 void maybeUpdate();
234 void cleanupSceneGraph();
235 void physicalDpiChanged();
236 void handleScreenChanged(QScreen *screen);
237 void runJobsAfterSwap();
238 void handleApplicationStateChanged(Qt::ApplicationState state);
239 void handleFontDatabaseChanged();
240private:
241#ifndef QT_NO_DEBUG_STREAM
242 inline friend QQmlInfo operator<<(QQmlInfo info, const QQuickWindow *window)
243 {
244 info.QDebug::operator<<(window);
245 return info;
246 }
247#endif
248
249 friend class QQuickItem;
250 friend class QQuickItemPrivate;
251 friend class QQuickWidget;
252 friend class QQuickRenderControl;
253 friend class QQuickAnimatorController;
254 friend class QQuickWidgetPrivate;
255 friend class QQuickDeliveryAgentPrivate;
256 Q_DISABLE_COPY(QQuickWindow)
257};
258
259#ifndef QT_NO_DEBUG_STREAM
260QDebug Q_QUICK_EXPORT operator<<(QDebug debug, const QQuickWindow *item);
261
262inline QQmlInfo operator<<(QQmlInfo info, const QWindow *window)
263{
264 info.QDebug::operator<<(window);
265 return info;
266}
267#endif
268
269QT_END_NAMESPACE
270
271Q_DECLARE_METATYPE(QQuickWindow *)
272
273#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
Combined button and popup list for selecting options.
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
QDebug operator<<(QDebug dbg, const NSObject *nsObject)
Definition qcore_mac.mm:203
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)