QQmlImageProviderBase Class
QQmlImageProviderBase 类用于在 QML 引擎中注册图像提供程序。更多内容...
| 头文件: | #include <QQmlImageProviderBase> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Qml) target_link_libraries(mytarget PRIVATE Qt6::Qml) |
| qmake: | QT += qml |
| 继承自: | QObject |
| 被继承者: |
公共类型
| enum | Flag { ForceAsynchronousImageLoading } |
| flags | Flags |
| enum | ImageType { Image, Pixmap, Texture, ImageResponse } |
公共函数
| virtual QQmlImageProviderBase::Flags | flags() const = 0 |
| virtual QQmlImageProviderBase::ImageType | imageType() const = 0 |
详细说明
图像提供程序必须在 QML 引擎中注册。QML 引擎所了解的关于图像提供程序的唯一信息,就是它们所提供的图像数据类型。若要使用图像提供程序获取图像数据,必须将 QQmlImageProviderBase 指针强制转换为QQuickImageProvider 指针。
另请参阅 QQuickImageProvider 和QQuickTextureFactory 。
成员类型文档
enum QQmlImageProviderBase::Flag
flags QQmlImageProviderBase::Flags
定义了该图像提供商的具体要求或功能。
| 常量 | 值 | 描述 |
|---|---|---|
QQmlImageProviderBase::ForceAsynchronousImageLoading | 0x01 | 确保向提供程序发出的映像请求在单独的线程中运行,这使得提供程序可以在不阻塞主线程的情况下,花费所需的时间来生成映像。 |
Flags 类型是QFlags<Flag> 的 typedef 定义。它存储 Flag 值的按“或”运算组合。
enum QQmlImageProviderBase::ImageType
定义此图像提供程序支持的图像类型。
| 常量 | 值 | 描述 |
|---|---|---|
QQmlImageProviderBase::Image | 1 | 该图像提供程序提供QImage 格式的图像。对于所有图像请求,都会调用QQuickImageProvider::requestImage()方法。 |
QQmlImageProviderBase::Pixmap | 2 | 该图像提供程序提供基于QPixmap 的图像。对于所有图像请求,都会调用QQuickImageProvider::requestPixmap()方法。 |
QQmlImageProviderBase::Texture | 3 | 图像提供程序提供基于QSGTextureProvider 的图像。对于所有图像请求,都会调用QQuickImageProvider::requestTexture()方法。 |
QQmlImageProviderBase::ImageResponse | 4 | 图像提供程序提供基于QQuickTextureFactory 的图像。仅应在QQuickAsyncImageProvider 或其子类中使用。所有图像请求都会调用QQuickAsyncImageProvider::requestImageResponse()方法。自Qt 5.6起 |
成员函数文档
[pure virtual] QQmlImageProviderBase::Flags QQmlImageProviderBase::flags() const
实现此方法以返回该图像提供程序的属性。
[pure virtual] QQmlImageProviderBase::ImageType QQmlImageProviderBase::imageType() const
实现此方法,以返回该图像提供程序所支持的图像类型。
© 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.