QQuickTextureFactory Class
QQuickTextureFactory 类为从 QML 加载自定义纹理提供了一个接口。更多
头文件: | #include <QQuickTextureFactory> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Quick) target_link_libraries(mytarget PRIVATE Qt6::Quick) |
qmake: | QT += quick |
继承: | QObject |
公共函数
QQuickTextureFactory() | |
virtual | ~QQuickTextureFactory() override |
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) |
成员函数文档
QQuickTextureFactory::QQuickTextureFactory()
构造纹理工厂。由于 QQuickTextureFactory 是抽象的,因此不能直接实例化。
[override virtual noexcept]
QQuickTextureFactory::~QQuickTextureFactory()
摧毁纹理工厂。
[pure virtual]
QSGTexture *QQuickTextureFactory::createTexture(QQuickWindow *window) const
该函数在场景图渲染线程上调用,从工厂创建一个QSGTexture 实例。window 提供了创建纹理的上下文。
QML 将根据需要在内部缓存返回的纹理。每次调用该函数都会返回一个唯一的实例。
调用此函数时,用于渲染的 OpenGL 上下文会被绑定。
[virtual]
QImage QQuickTextureFactory::image() const
返回此纹理的图像版本。
返回图像的寿命未知,因此应返回一个自包含的QImage ,而不是使用QImage(uchar *, ...)构造函数。
该函数不常用,运行速度较慢。
[pure virtual]
int QQuickTextureFactory::textureByteCount() const
返回纹理消耗的内存字节数。
[static]
QQuickTextureFactory *QQuickTextureFactory::textureFactoryForImage(const QImage &image)
返回持有给定image 的QQuickTextureFactory 。
它通常用作QQuickImageResponse::textureFactory 中的辅助工具。
[pure virtual]
QSize QQuickTextureFactory::textureSize() const
返回纹理的大小。此函数将由任意线程调用,不应依赖于 OpenGL 上下文绑定。
© 2025 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.