Qt 6.x
The Qt SDK
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
4#ifndef QQUICKWINDOW_H
5#define QQUICKWINDOW_H
6
7#include <QtQuick/qtquickglobal.h>
8#include <QtQuick/qsgrendererinterface.h>
9
10#include <QtCore/qmetatype.h>
11#include <QtGui/qwindow.h>
12#include <QtGui/qevent.h>
13#include <QtQml/qqml.h>
14#include <QtQml/qqmldebug.h>
15#include <QtQml/qqmlinfo.h>
16
18
19class QRunnable;
20class QQuickItem;
21class QSGTexture;
30class QSGImageNode;
32class QQuickPalette;
36class QRhi;
37class QRhiSwapChain;
38class QRhiTexture;
39
40class Q_QUICK_EXPORT QQuickWindow : public QWindow
41{
43 Q_PRIVATE_PROPERTY(QQuickWindow::d_func(), QQmlListProperty<QObject> data READ data DESIGNABLE false)
45 Q_PROPERTY(QQuickItem* contentItem READ contentItem CONSTANT)
46 Q_PROPERTY(QQuickItem* activeFocusItem READ activeFocusItem NOTIFY activeFocusItemChanged REVISION(2, 1) FINAL)
47 Q_PRIVATE_PROPERTY(QQuickWindow::d_func(), QQuickPalette *palette READ palette WRITE setPalette
48 RESET resetPalette NOTIFY paletteChanged REVISION(6, 2))
49 QDOC_PROPERTY(QWindow* transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged)
50 Q_CLASSINFO("DefaultProperty", "data")
51 Q_DECLARE_PRIVATE(QQuickWindow)
52
56public:
57 enum CreateTextureOption {
58 TextureHasAlphaChannel = 0x0001,
59 TextureHasMipmaps = 0x0002,
60 TextureOwnsGLTexture = 0x0004,
61 TextureCanUseAtlas = 0x0008,
62 TextureIsOpaque = 0x0010
63 };
64
65 enum RenderStage {
66 BeforeSynchronizingStage,
67 AfterSynchronizingStage,
68 BeforeRenderingStage,
69 AfterRenderingStage,
70 AfterSwapStage,
71 NoStage
72 };
73
74 Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)
75 Q_FLAG(CreateTextureOptions)
76
77 enum SceneGraphError {
78 ContextNotAvailable = 1
79 };
80 Q_ENUM(SceneGraphError)
81
82 enum TextRenderType {
83 QtTextRendering,
84 NativeTextRendering
85 };
86 Q_ENUM(TextRenderType)
87
88 explicit QQuickWindow(QWindow *parent = nullptr);
89 explicit QQuickWindow(QQuickRenderControl *renderControl);
90
91 ~QQuickWindow() override;
92
93 QQuickItem *contentItem() const;
94
95 QQuickItem *activeFocusItem() const;
96 QObject *focusObject() const override;
97
98 QQuickItem *mouseGrabberItem() const;
99
100 QImage grabWindow();
101
102 void setRenderTarget(const QQuickRenderTarget &target);
103 QQuickRenderTarget renderTarget() const;
104
105 struct GraphicsStateInfo {
106 int currentFrameSlot;
107 int framesInFlight;
108 };
109 const GraphicsStateInfo &graphicsStateInfo();
110 void beginExternalCommands();
111 void endExternalCommands();
112 QQmlIncubationController *incubationController() const;
113
114#if QT_CONFIG(accessibility)
115 QAccessibleInterface *accessibleRoot() const override;
116#endif
117
118 // Scene graph specific functions
119 QSGTexture *createTextureFromImage(const QImage &image) const;
120 QSGTexture *createTextureFromImage(const QImage &image, CreateTextureOptions options) const;
121 QSGTexture *createTextureFromRhiTexture(QRhiTexture *texture, CreateTextureOptions options = {}) const;
122
123 void setColor(const QColor &color);
124 QColor color() const;
125
126 static bool hasDefaultAlphaBuffer();
127 static void setDefaultAlphaBuffer(bool useAlpha);
128
129 void setPersistentGraphics(bool persistent);
130 bool isPersistentGraphics() const;
131
132 void setPersistentSceneGraph(bool persistent);
133 bool isPersistentSceneGraph() const;
134
135 bool isSceneGraphInitialized() const;
136
137 void scheduleRenderJob(QRunnable *job, RenderStage schedule);
138
139 qreal effectiveDevicePixelRatio() const;
140
141 QSGRendererInterface *rendererInterface() const;
142
143 static void setGraphicsApi(QSGRendererInterface::GraphicsApi api);
144 static QSGRendererInterface::GraphicsApi graphicsApi();
145
146 static void setSceneGraphBackend(const QString &backend);
147 static QString sceneGraphBackend();
148
149 void setGraphicsDevice(const QQuickGraphicsDevice &device);
150 QQuickGraphicsDevice graphicsDevice() const;
151
152 void setGraphicsConfiguration(const QQuickGraphicsConfiguration &config);
153 QQuickGraphicsConfiguration graphicsConfiguration() const;
154
155 QSGRectangleNode *createRectangleNode() const;
157 QSGNinePatchNode *createNinePatchNode() const;
158
159 static TextRenderType textRenderType();
160 static void setTextRenderType(TextRenderType renderType);
161
162 QRhi *rhi() const;
163 QRhiSwapChain *swapChain() const;
164
170 Q_REVISION(2, 2) void afterSynchronizing();
171 void beforeRendering();
172 void afterRendering();
173 Q_REVISION(2, 2) void afterAnimating();
174 Q_REVISION(2, 2) void sceneGraphAboutToStop();
175
176 Q_REVISION(2, 1) void closing(QQuickCloseEvent *close);
177 void colorChanged(const QColor &);
178 Q_REVISION(2, 1) void activeFocusItemChanged();
179 Q_REVISION(2, 2) void sceneGraphError(QQuickWindow::SceneGraphError error, const QString &message);
180
181 Q_REVISION(2, 14) void beforeRenderPassRecording();
182 Q_REVISION(2, 14) void afterRenderPassRecording();
183
184 Q_REVISION(6, 0) void paletteChanged();
185 Q_REVISION(6, 0) void paletteCreated();
186
187 Q_REVISION(6, 0) void beforeFrameBegin();
188 Q_REVISION(6, 0) void afterFrameEnd();
189
190public Q_SLOTS:
191 void update();
192 void releaseResources();
193
194protected:
197
198 void exposeEvent(QExposeEvent *) override;
199 void resizeEvent(QResizeEvent *) override;
200
201 void showEvent(QShowEvent *) override;
202 void hideEvent(QHideEvent *) override;
203 void closeEvent(QCloseEvent *) override;
204
205 void focusInEvent(QFocusEvent *) override;
206 void focusOutEvent(QFocusEvent *) override;
207
208 bool event(QEvent *) override;
209
210 // These overrides are no longer normal entry points for
211 // input events, but kept in case legacy code calls them.
212 void keyPressEvent(QKeyEvent *) override;
213 void keyReleaseEvent(QKeyEvent *) override;
214 void mousePressEvent(QMouseEvent *) override;
215 void mouseReleaseEvent(QMouseEvent *) override;
216 void mouseDoubleClickEvent(QMouseEvent *) override;
217 void mouseMoveEvent(QMouseEvent *) override;
218#if QT_CONFIG(wheelevent)
219 void wheelEvent(QWheelEvent *) override;
220#endif
221#if QT_CONFIG(tabletevent)
222 void tabletEvent(QTabletEvent *) override;
223#endif
224
225private Q_SLOTS:
226 void maybeUpdate();
227 void cleanupSceneGraph();
228 void physicalDpiChanged();
230 void setTransientParent_helper(QQuickWindow *window);
231 void runJobsAfterSwap();
232 void handleApplicationStateChanged(Qt::ApplicationState state);
233 void handleFontDatabaseChanged();
234private:
235#ifndef QT_NO_DEBUG_STREAM
237 {
238 info.QDebug::operator<<(window);
239 return info;
240 }
241#endif
242
243 friend class QQuickItem;
244 friend class QQuickWidget;
249 Q_DISABLE_COPY(QQuickWindow)
250};
251
252#ifndef QT_NO_DEBUG_STREAM
253QDebug Q_QUICK_EXPORT operator<<(QDebug debug, const QQuickWindow *item);
254
256{
257 info.QDebug::operator<<(window);
258 return info;
259}
260#endif
261
263
265
266#endif // QQUICKWINDOW_H
267
static void handleScreenChanged(JNIEnv *, jclass, jint displayId)
IOBluetoothDevice * device
The QCloseEvent class contains parameters that describe a close event.
Definition qevent.h:561
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
\inmodule QtCore
Definition qcoreevent.h:45
The QExposeEvent class contains event parameters for expose events. \inmodule QtGui.
Definition qevent.h:514
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:469
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition qevent.h:585
\inmodule QtGui
Definition qimage.h:37
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:624
The QKeyEvent class describes a key event.
Definition qevent.h:423
\inmodule QtGui
Definition qevent.h:195
\inmodule QtCore
Definition qobject.h:90
QQmlIncubationController instances drive the progress of QQmlIncubators.
\inmodule QtQml
Definition qqmlinfo.h:30
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
\qmlsignal QtQuick::Window::sceneGraphError(SceneGraphError error, QString message)
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow.
The QQuickGraphicsDevice class provides an opaque container for native graphics objects representing ...
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
Contains color groups for each QML item state. \inmodule QtQuick.
The QQuickRenderControl class provides a mechanism for rendering the Qt Quick scenegraph onto an offs...
The QQuickRenderTarget class provides an opaque container for native graphics resources specifying a ...
\module QtQuickWidgets \title Qt Quick Widgets C++ Classes
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
void frameSwapped()
This signal is emitted when a frame has been queued for presenting.
void beforeSynchronizing()
This signal is emitted before the scene graph is synchronized with the QML state.
Q_REVISION(2, 2) void afterSynchronizing()
void sceneGraphInitialized()
\qmlsignal QtQuick::Window::frameSwapped()
void sceneGraphInvalidated()
\qmlsignal QtQuick::Window::sceneGraphInitialized()
friend QQmlInfo operator<<(QQmlInfo info, const QQuickWindow *window)
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:547
\inmodule QtGui
Definition qrhi.h:1513
\inmodule QtGui
Definition qrhi.h:883
\inmodule QtGui
Definition qrhi.h:1767
\inmodule QtCore
Definition qrunnable.h:18
The QSGImageNode class is provided for convenience to easily draw textured content using the QML scen...
\inmodule QtQuick
The QSGRectangleNode class is a convenience class for drawing solid filled rectangles using scenegrap...
An interface providing access to some of the graphics API specific internals of the scenegraph.
GraphicsApi
\value Unknown An unknown graphics API is in use \value Software The Qt Quick 2D Renderer is in use \...
\inmodule QtQuick
Definition qsgtexture.h:20
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:577
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtGui
Definition qwindow.h:63
virtual QAccessibleInterface * accessibleRoot() const
Returns the accessibility interface for the object that the window represents.
Definition qwindow.cpp:2150
virtual QObject * focusObject() const
Returns the QObject that will be the final receiver of events tied focus, such as key events.
Definition qwindow.cpp:2168
[Window class with invokable method]
Definition window.h:11
void colorChanged()
else opt state
[0]
Combined button and popup list for selecting options.
ApplicationState
Definition qnamespace.h:261
Definition image.cpp:4
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError * error
EGLConfig config
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_METATYPE(TYPE)
Definition qmetatype.h:1504
GLenum target
GLenum GLuint texture
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
struct _cl_event * event
#define QML_NAMED_ELEMENT(NAME)
#define QML_REMOVED_IN_VERSION(MAJOR, MINOR)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
QDebug Q_QUICK_EXPORT operator<<(QDebug debug, const QQuickWindow *item)
static QSvgNode * createImageNode(QSvgNode *parent, const QXmlStreamAttributes &attributes, QSvgHandler *handler)
QScreen * screen
[1]
Definition main.cpp:29
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_CLASSINFO(name, value)
#define Q_FLAG(x)
#define Q_SLOTS
#define QDOC_PROPERTY(text)
#define Q_SIGNALS
#define Q_PRIVATE_PROPERTY(d, text)
double qreal
Definition qtypes.h:92
QFileInfo info(fileName)
[8]
QGraphicsItem * item
myFilter setColor(QColor(128, 0, 0))
aWidget window() -> setWindowTitle("New Window Title")
[2]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent