The QQuickFramebufferObject class is a convenience class for integrating OpenGL rendering using a framebuffer object (FBO) with Qt Quick. More...
|qmake:||QT += quick|
This class was introduced in Qt 5.2.
|QQuickFramebufferObject(QQuickItem *parent = nullptr)|
|virtual QQuickFramebufferObject::Renderer *||createRenderer() const = 0|
|virtual bool||isTextureProvider() const override|
|virtual void||releaseResources() override|
|virtual QSGTextureProvider *||textureProvider() const override|
On most platforms, the rendering will occur on a dedicated thread. For this reason, the QQuickFramebufferObject class enforces a strict separation between the item implementation and the FBO rendering. All item logic, such as properties and UI-related helper functions needed by QML should be located in a QQuickFramebufferObject class subclass. Everything that relates to rendering must be located in the QQuickFramebufferObject::Renderer class.
Warning: This class is only functional when Qt Quick is rendering via OpenGL, either directly or through the RHI-based rendering path. It is not compatible with other RHI backends, such as, Vulkan or Metal.
To avoid race conditions and read/write issues from two threads it is important that the renderer and the item never read or write shared variables. Communication between the item and the renderer should primarily happen via the QQuickFramebufferObject::Renderer::synchronize() function. This function will be called on the render thread while the GUI thread is blocked.
Using queued connections or events for communication between item and renderer is also possible.
Both the Renderer and the FBO are memory managed internally.
The size of the FBO will by default adapt to the size of the item. If a fixed size is preferred, set textureFollowsItemSize to
false and return a texture of your choosing from QQuickFramebufferObject::Renderer::createFramebufferObject().
This property controls if the size of the FBO's contents should be mirrored vertically when drawing. This allows easy integration of third-party rendering code that does not follow the standard expectations.
The default value is
This property was introduced in Qt 5.6.
This property controls if the size of the FBO's texture should follow the dimensions of the QQuickFramebufferObject item. When this property is false, the FBO will be created once the first time it is displayed. If it is set to true, the FBO will be recreated every time the dimensions of the item change.
The default value is
Member Function Documentation
QQuickFramebufferObject::QQuickFramebufferObject(QQuickItem *parent = nullptr)
Constructs a new QQuickFramebufferObject with parent parent.
[pure virtual] QQuickFramebufferObject::Renderer *QQuickFramebufferObject::createRenderer() const
Reimplement this function to create a renderer used to render into the FBO.
This function will be called on the rendering thread while the GUI thread is blocked.
Reimplements: QQuickItem::isTextureProvider() const.
[override virtual] QSGTextureProvider *QQuickFramebufferObject::textureProvider() const
Reimplements: QQuickItem::textureProvider() const.
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.