Changes to Qt Quick▲
Qt 6 is a result of the conscious effort to make the framework more efficient and easy to use.
We try to maintain binary and source compatibility for all the public APIs in each release. But some changes were inevitable in an effort to make Qt a better framework.
In this topic we summarize those changes in Qt Quick, and provide guidance to handle them.
Changes to Qt Quick QML Types▲
Changed Type of font.weight▲
The type of font.weight has been changed to int. The pre-defined weight classes still exist, but it is now possible to use arbitrary integers to select fonts which do not match any of these weight classes. This ensures parity with the C++ API, where it has always been possible to express the font weight as an arbitrary integer.
Most code will be unaffected by this change, except in the case where an implicit conversion from a string to enum value was used.
font.weight: "Bold"This code will no longer parse correctly and has to be replaced by its equivalent enum value, as demonstrated below.
font.weight: Font.BoldFontLoader.name Is Now a Read-Only Property▲
In Qt 5, the name property of https:// was writable and would override the source property of the item when set. This caused some confusion as to its purpose and could cause undeterministic behavior if there was a race condition between the setters for the conflicting properties.
This means that code such as the following will no longer work.
FontLoader {
id: fontLoader
name: "Helvetica"
}
Text {
font.family: fontLoader.name
text: "Foobar"
}Instead, use a custom property to store font family names.
property string fontName: "Helvetica"
Text {
font.family: fontName
text: "Foobar"
}The OpenGLInfo QML Type Is Removed▲
In Qt 5.8, OpenGLInfo was deprecated and is removed for Qt 6. Please use https:// instead.
ShaderEffect No Longer Supports Inline GLSL Shader Strings▲
Just like with https://, the effects are no longer specified in form of GLSL shader strings. Rather, shaders are expected to be preprocessed by the tools from the Qt Shader Tools module, such as the qsb command line tool, thus ensuring the shader assets are usable regardless of which graphics API (Vulkan, Metal, OpenGL, or Direct 3D) is used at runtime. https:// items are expected to reference the resulting .qsb files.
ShaderEffect Source Properties Are Now URLs▲
The https:// properties https:// and https:// both have a type of https:// now, instead of https://. Their behavior is therefore identical to other similar properties, such as https://. Existing code that refers to files via the file or qrc scheme will continue to work as-is. In addition, this change allows referring to files with a path relative to the component's (the .qml file's) location. Specifying the file: scheme is therefore optional now.
Changes to Qt Quick C++ APIs▲
Changes to QQuickItem▲
https://'s geometryChanged() function was renamed to https://().
Changes to QQuickWidget▲
https:// is functional only when the scenegraph is rendering with OpenGL. It will not be functional when using another graphics API, such as Vulkan or Metal. Applications relying on https:// should force the usage of OpenGL by calling QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL) in their main() function.
Changes to QQuick* APIs▲
-
Applications wishing to integrate their own set of Vulkan, Metal, or Direct3D rendering commands should be aware of new https:// signals in addition to https://() and afterRendering(). The existing Qt 5 pattern of connecting to just beforeRendering or afterRendering is often not sufficient anymore on its own, and will likely need to be complemented by connecting to additional signals, such as https://() or https://().
-
Applications that rely on the https://() or afterRendering() signals to issue their own set of OpenGL rendering commands should call https://() before, and https://() after, the OpenGL calls. This ensures that state changes made by the application code does not lead to confusion with regards to the scene graph renderer's own cached state. Note however, that, just like in Qt 5, changing OpenGL 3.x or 4.x state that is not used by the Qt Quick renderer can still lead to unexpected issues, so therefore application are advised to reset any such OpenGL state to the default value before returning from the slots or lambdas connected to these signals.
-
The existing https://() overloads, and the related getters, are removed and replaced by a new function taking a https://. Applications performing redirected rendering in combination with https:// are now expected to use this new function to specify the render target in a manner that is not tied to OpenGL.
-
The https://() overload taking a https:// argument has been renamed to https://().
-
The https:// functions setPersistentOpenGLContext and isPersistentOpenGLContext are renamed, and are now https://() and https://().
-
setClearBeforeRendering() and clearBeforeRendering() have been removed from https://. There is no option for skipping the color buffer clearing in Qt 6. Calling setClearBeforeRendering() was often necessary in Qt 5 in combination with underlays, to prevent Qt Quick from clearing the content rendered into the color buffer. In Qt 6, there is a more robust approach: connecting to the beforeRenderPassRecording() signal, that is emitted after clearing, but before rendering Qt Quick's content.
-
The QQuickWindow::openglContext() function has been removed. When the application has ensured the scene graph is using OpenGL for rendering, it can query the https:// from https://().
-
The QQuickWindow::openglContextCreated() signal has been removed.
-
The deprecated QQuickWindow::createTextureFromId() function has been removed. Instead, use the fromNative() function from QPlatformInterface::QSGOpenGLTexture, QPlatformInterface::QSGVulkanTexture, QPlatformInterface::QSGD3D11Texture, or QPlatformInterface::QSGMetalTexture.
-
The https:// class is available with an unchanged API, but is only functional when the scenegraph is rendering with OpenGL. It will not be functional when using another graphics API, such as Vulkan or Metal. Applications relying on https:// should force the usage of OpenGL by calling QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL) in their main() function.
-
https:// has a slightly changed API: grab() is now removed, use https://() instead, where applicable. The initialize() function no longer takes a https://. Applications are now also required to call https://() and https://() as appropriate. When multisampling is desired, the new function https://() must be called to indicate the sample count.
-
Applications wishing to perform Qt Quick rendering in combination with an existing native graphics device or context object must take the new https://() function into use as https:// no longer provides the initialize(QOpenGLContext*) function.
-
Setting https:// and https:// to Framebuffer mode has no effect. It will behave as if the mode was set to the default Image mode.
-
The environment variable QSG_NO_DEPTH_BUFFER is still supported in Qt 6.0, but its usage is recommended to be replaced by calling https://() on a https:// that is then associated with the https://.
Changes to QSG* APIs▲
-
https:// has a changed interface. Implementations should not rely on OpenGL anymore, and cannot assume that functions, such as the now-removed updateState(), are called with a https:// current. In the new, data-oriented interface updateState() is replaced by https://(), https://(), and https://(). Instead of GLSL shader code provided as strings, shaders are now expected to be preprocessed by the tools from the Qt Shader Tools module, such as the qsb command line tool, thus ensuring the shader assets are usable regardless of which graphics API (Vulkan, Metal, OpenGL, or Direct 3D) is used at run time.
-
QSGEngine has been removed. In the unlikely case of an application utilizing this class, it is recommended to port to using https:// instead.
-
QSGAbstractRenderer is no longer public. The usage of this class made sense only in combination with QSGEngine, and with that class being removed QSGAbstractRenderer has been moved back to private.
-
The QSGSimpleMaterial convenience class has been removed. Applications are expected to use the revised, OpenGL-independent https:// APIs instead.
-
To access the underlying native texture object for a https://, textureId() is no longer available. Instead, use QSGTexture::platformInterface() with QPlatformInterface::QSGOpenGLTexture, QPlatformInterface::QSGVulkanTexture, QPlatformInterface::QSGD3D11Texture, or QPlatformInterface::QSGMetalTexture.
-
Subclasses of https:// are now required to override new additional virtuals, such as setAnisotropyLevel() and anisotropyLevel().
-
Subclasses of https:// will likely need to be redesigned. Some of the OpenGL-specific virtual functions, such as bind() or updateBindOptions(), are no longer present, while there are new virtuals that are mandatory to implement, such as https://().
Changes to OpenGL Use in Qt Quick▲
While it will present no breaks for many applications, application developers should be aware that, OpenGL is not always the default choice anymore for Qt Quick rendering in Qt 6. Unless the software backend is used, a Qt Quick application could use OpenGL, Vulkan, Metal, or Direct3D 11 at runtime. When no explicit request is made, either via the QSG_RHI_BACKEND environment variable or the https://() function, a platform-specific default is chosen by Qt Quick.
For more information, visit the https:// and the https:// pages.


