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
qt6-changes.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2020 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page quick-changes-qt6.html
6
\title Changes to Qt Quick
7
\ingroup changes-qt-5-to-6
8
\brief Migrate Qt Quick to Qt 6.
9
10
Qt 6 is a result of the conscious effort to make the framework more
11
efficient and easy to use.
12
13
We try to maintain binary and source compatibility for all the public
14
APIs in each release. But some changes were inevitable in an effort to
15
make Qt a better framework.
16
17
In this topic we summarize those changes in Qt Quick, and provide
18
guidance to handle them.
19
20
21
\section1 Changes to Qt Quick QML Types
22
23
\section2 Changed Type of font.weight
24
25
The type of \c font.weight has been changed to \c int. The pre-defined
26
weight classes still exist, but it is now possible to use arbitrary integers
27
to select fonts which do not match any of these weight classes. This ensures
28
parity with the C++ API, where it has always been possible to express the
29
font weight as an arbitrary integer.
30
31
Most code will be unaffected by this change, except in the case where an
32
implicit conversion from a string to enum value was used.
33
34
\code
35
font.weight: "Bold"
36
\endcode
37
38
This code will no longer parse correctly and has to be replaced by its
39
equivalent enum value, as demonstrated below.
40
41
\code
42
font.weight: Font.Bold
43
\endcode
44
45
\section2 FontLoader.name Is Now a Read-Only Property
46
47
In Qt 5, the \c name property of FontLoader was writable and would override
48
the source property of the item when set. This caused some confusion as to
49
its purpose and could cause undeterministic behavior if there was a race
50
condition between the setters for the conflicting properties.
51
52
This means that code such as the following will no longer work.
53
54
\code
55
FontLoader {
56
id: fontLoader
57
name: "Helvetica"
58
}
59
60
Text {
61
font.family: fontLoader.name
62
text: "Foobar"
63
}
64
\endcode
65
66
Instead, use a custom property to store font family names.
67
68
\code
69
property string fontName: "Helvetica"
70
71
Text {
72
font.family: fontName
73
text: "Foobar"
74
}
75
\endcode
76
77
\section2 The OpenGLInfo QML Type Is Removed
78
79
In Qt 5.8, OpenGLInfo was deprecated and is removed for Qt 6.
80
Please use GraphicsInfo instead.
81
82
\section1 ShaderEffect No Longer Supports Inline GLSL Shader Strings
83
84
Just like with \l{QSGMaterial}{custom materials}, the effects are no longer
85
specified in form of GLSL shader strings. Rather, shaders are expected to be
86
preprocessed by the tools from the \l{Qt Shader Tools} module, such as the
87
\c qsb command line tool, thus ensuring the shader assets are usable
88
regardless of which graphics API (Vulkan, Metal, OpenGL, or Direct 3D) is
89
used at runtime. ShaderEffect items are expected to reference the resulting
90
\c{.qsb} files.
91
92
\section2 ShaderEffect Source Properties Are Now URLs
93
94
The ShaderEffect properties \l{ShaderEffect::vertexShader}{vertexShader} and
95
\l{ShaderEffect::fragmentShader}{fragmentShader} both have a type of QUrl
96
now, instead of QByteArray. Their behavior is therefore identical to other
97
similar properties, such as \l{Image::source}{Image.source}. Existing code
98
that refers to files via the \c file or \c qrc scheme will continue to work
99
as-is. In addition, this change allows referring to files with a path
100
relative to the component's (the .qml file's) location. Specifying the
101
\c{file:} scheme is therefore optional now.
102
103
104
\section1 Changes to Qt Quick C++ APIs
105
106
\section2 Changes to QQuickItem
107
108
QQuickItem's geometryChanged() function was renamed to
109
\l{QQuickItem::}{geometryChange()}.
110
111
\section2 Changes to QQuick* APIs
112
113
\list
114
115
\li Applications wishing to integrate their own set of Vulkan, Metal, or
116
Direct3D rendering commands should be aware of new QQuickWindow signals in
117
addition to QQuickWindow::beforeRendering() and afterRendering(). The
118
existing Qt 5 pattern of connecting to just beforeRendering or
119
afterRendering is often not sufficient anymore on its own, and will likely
120
need to be complemented by connecting to additional signals, such as
121
\l{QQuickWindow::beforeRenderPassRecording()}{beforeRenderPassRecording()}
122
or \l{QQuickWindow::afterRenderPassRecording()}{afterRenderPassRecording()}.
123
124
\li Applications that rely on the QQuickWindow::beforeRendering() or
125
afterRendering() signals to issue their own set of OpenGL rendering commands
126
should call QQuickWindow::beginExternalCommands() before, and
127
QQuickWindow::endExternalCommands() after, the OpenGL calls. This ensures
128
that state changes made by the application code does not lead to confusion
129
with regards to the scene graph renderer's own cached state. Note however,
130
that, just like in Qt 5, changing OpenGL 3.x or 4.x state that is not used
131
by the Qt Quick renderer can still lead to unexpected issues, so therefore
132
application are advised to reset any such OpenGL state to the default value
133
before returning from the slots or lambdas connected to these signals.
134
135
\li The existing QQuickWindow::setRenderTarget() overloads, and the
136
related getters, are removed and replaced by a new function taking a
137
QQuickRenderTarget. Applications performing redirected rendering in
138
combination with QQuickRenderControl are now expected to use this new
139
function to specify the render target in a manner that is not tied to
140
OpenGL.
141
142
\li The QQuickWindow::setSceneGraphBackend() overload taking a
143
QSGRendererInterface::GraphicsApi argument has been renamed to
144
\l{QQuickWindow::setGraphicsApi()}{setGraphicsApi()}.
145
146
\li The QQuickWindow functions setPersistentOpenGLContext and
147
isPersistentOpenGLContext are renamed, and are now
148
QQuickWindow::setPersistentGraphics() and
149
QQuickWindow::isPersistentGraphics().
150
151
\li setClearBeforeRendering() and clearBeforeRendering() have been removed
152
from QQuickWindow. There is no option for skipping the color buffer clearing
153
in Qt 6. Calling setClearBeforeRendering() was often necessary in Qt 5 in
154
combination with underlays, to prevent Qt Quick from clearing the content
155
rendered into the color buffer. In Qt 6, there is a more robust approach:
156
connecting to the \c beforeRenderPassRecording() signal,
157
that is emitted after clearing, but before rendering Qt Quick's content.
158
159
160
\li The QQuickWindow::openglContext() function has been removed. When the
161
application has ensured the scene graph is using OpenGL for rendering, it
162
can query the QOpenGLContext from QSGRendererInterface::getResource().
163
164
\li The QQuickWindow::openglContextCreated() signal has been removed.
165
166
\li The deprecated QQuickWindow::createTextureFromId() function has been
167
removed. Instead, use the fromNative() function from
168
QPlatformInterface::QSGOpenGLTexture, QPlatformInterface::QSGVulkanTexture,
169
QPlatformInterface::QSGD3D11Texture, or QPlatformInterface::QSGMetalTexture.
170
171
\li The QQuickFramebufferObject class is available with an unchanged API,
172
but is only functional when the scenegraph is rendering with OpenGL. It will
173
not be functional when using another graphics API, such as Vulkan or Metal.
174
Applications relying on QQuickFramebufferObject should force the usage of
175
OpenGL by calling
176
\c{QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL)} in their
177
main() function.
178
179
\li QQuickRenderControl has a slightly changed API: grab() is now
180
removed, use QQuickWindow::grabWindow() instead, where applicable. The
181
initialize() function no longer takes a QOpenGLContext. Applications are
182
now also required to call QQuickRenderControl::beginFrame() and
183
QQuickRenderControl::endFrame() as appropriate. When multisampling is
184
desired, the new function QQuickRenderControl::setSamples() must be
185
called to indicate the sample count.
186
187
\li Applications wishing to perform Qt Quick rendering in combination
188
with an existing native graphics device or context object must take the
189
new QQuickWindow::setGraphicsDevice() function into use as
190
QQuickRenderControl no longer provides the
191
\c{initialize(QOpenGLContext*)} function.
192
193
\li Setting QQuickPaintedItem and Context2D to \c Framebuffer mode has
194
no effect. It will behave as if the mode was set to the default Image
195
mode.
196
197
\li The environment variable \c{QSG_NO_DEPTH_BUFFER} is still supported in
198
Qt 6.0, but its usage is recommended to be replaced by calling
199
\l{QQuickGraphicsConfiguration::setDepthBufferFor2D()}{setDepthBufferFor2D()}
200
on a QQuickGraphicsConfiguration that is then associated with the
201
QQuickWindow.
202
203
\endlist
204
205
\section1 Changes to QSG* APIs
206
207
\list
208
209
\li QSGMaterialShader has a changed interface. Implementations should
210
not rely on OpenGL anymore, and cannot assume that functions, such as
211
the now-removed updateState(), are called with a QOpenGLContext
212
current. In the new, data-oriented interface updateState() is replaced
213
by \l{QSGMaterialShader::updateUniformData()}{updateUniformData()},
214
\l{QSGMaterialShader::updateSampledImage()}{updateSampledImage()}, and
215
\l{QSGMaterialShader::updateGraphicsPipelineState()}{updateGraphicsPipelineState()}.
216
Instead of GLSL shader code provided as strings, shaders are now
217
expected to be preprocessed by the tools from the Qt Shader Tools
218
module, such as the \c qsb command line tool, thus ensuring the shader
219
assets are usable regardless of which graphics API (Vulkan, Metal,
220
OpenGL, or Direct 3D) is used at run time.
221
222
\li QSGEngine has been removed. In the unlikely case of an application
223
utilizing this class, it is recommended to port to using
224
QQuickRenderControl instead.
225
226
\li QSGAbstractRenderer is no longer public. The usage of this class made
227
sense only in combination with QSGEngine, and with that class being
228
removed QSGAbstractRenderer has been moved back to private.
229
230
\li The QSGSimpleMaterial convenience class has been
231
removed. Applications are expected to use the revised, OpenGL-independent
232
QSGMaterial APIs instead.
233
234
\li To access the underlying native texture object for a QSGTexture,
235
textureId() is no longer available. Instead, use
236
QSGTexture::platformInterface() with QPlatformInterface::QSGOpenGLTexture,
237
QPlatformInterface::QSGVulkanTexture, QPlatformInterface::QSGD3D11Texture,
238
or QPlatformInterface::QSGMetalTexture.
239
240
\li Subclasses of QSGImageNode are now required to override new
241
additional virtuals, such as setAnisotropyLevel() and anisotropyLevel().
242
243
\li Subclasses of QSGTexture will likely need to be redesigned. Some of
244
the OpenGL-specific virtual functions, such as bind() or
245
updateBindOptions(), are no longer present, while there are new virtuals
246
that are mandatory to implement, such as
247
\l{QSGTexture::comparisonKey()}{comparisonKey()}.
248
249
\endlist
250
251
\section1 Changes to OpenGL Use in Qt Quick
252
253
While it will present no breaks for many applications, application
254
developers should be aware that, OpenGL is not always the default choice
255
anymore for Qt Quick rendering in Qt 6. Unless the \c software backend is
256
used, a Qt Quick application could use OpenGL, Vulkan, Metal, or Direct3D 11
257
at runtime. When no explicit request is made, either via the
258
\c QSG_RHI_BACKEND environment variable or the
259
QQuickWindow::setSceneGraphBackend() function, a platform-specific
260
default is chosen by Qt Quick.
261
262
For more information, visit the \l{Qt Quick Scene Graph} and the
263
\l{Qt Quick Scene Graph Default Renderer} pages.
264
265
266
*/
qtdeclarative
src
quick
doc
src
qt6-changes.qdoc
Generated on
for Qt by
1.14.0