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 上下文。
© 2026 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.