The QQuickTextureFactory class provides an interface for loading custom textures from QML. More...
|CMake:|| find_package(Qt6 COMPONENTS Quick REQUIRED) |
target_link_libraries(mytarget PRIVATE Qt6::Quick)
|qmake:||QT += quick|
|virtual QSGTexture *||createTexture(QQuickWindow *window) const = 0|
|virtual QImage||image() const|
|virtual int||textureByteCount() const = 0|
|virtual QSize||textureSize() const = 0|
|QQuickTextureFactory *||textureFactoryForImage(const QImage &image)|
The purpose of the texture factory is to provide a placeholder for a image data that can be converted into an OpenGL texture.
Creating a texture directly is not possible as there is rarely an OpenGL context available in the thread that is responsible for loading the image data.
Member Function Documentation
Constructs a texture factory. Since QQuickTextureFactory is abstract, it cannot be instantiated directly.
Destroys the texture factory.
[pure virtual] QSGTexture *QQuickTextureFactory::createTexture(QQuickWindow *window) const
This function is called on the scene graph rendering thread to create a QSGTexture instance from the factory. window provides the context which this texture is created in.
QML will internally cache the returned texture as needed. Each call to this function should return a unique instance.
The OpenGL context used for rendering is bound when this function is called.
[virtual] QImage QQuickTextureFactory::image() const
Returns an image version of this texture.
This function is not commonly used and is expected to be slow.
Returns the number of bytes of memory the texture consumes.
[static, since 5.6] QQuickTextureFactory *QQuickTextureFactory::textureFactoryForImage(const QImage &image)
Returns a QQuickTextureFactory holding the given image.
This is typically used as a helper in QQuickImageResponse::textureFactory.
This function was introduced in Qt 5.6.
[pure virtual] QSize QQuickTextureFactory::textureSize() const
Returns the size of the texture. This function will be called from arbitrary threads and should not rely on an OpenGL context bound.
© 2021 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.