QQmlImageProviderBase Class

QQmlImageProviderBase 类用于在 QML 引擎中注册图像提供程序。更多

Header: #include <QQmlImageProviderBase>
CMake: find_package(Qt6 REQUIRED COMPONENTS Qml)
target_link_libraries(mytarget PRIVATE Qt6::Qml)
qmake: QT += qml
继承: QObject
继承于:

QQuickImageProvider

公共类型

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 指针。

另请参阅 QQuickImageProviderQQuickTextureFactory

成员类型文档

枚举 QQmlImageProviderBase::Flag
flags QQmlImageProviderBase::Flags

定义此图像提供程序的特定要求或功能。

常量描述
QQmlImageProviderBase::ForceAsynchronousImageLoading0x01确保向提供程序发出的图像请求在单独的线程中运行,这样提供程序就可以在不阻塞主线程的情况下花费尽可能多的时间来生成图像。

Flags 类型是QFlags<Flag> 的类型定义。它存储 Flag 值的 OR 组合。

enum QQmlImageProviderBase::ImageType

定义此图像提供程序支持的图像类型。

常数描述
QQmlImageProviderBase::Image1图片提供程序提供QImage 图片。所有图像请求都将调用QQuickImageProvider::requestImage() 方法。
QQmlImageProviderBase::Pixmap2图像提供程序提供QPixmap 图像。所有图像请求都将调用QQuickImageProvider::requestPixmap() 方法。
QQmlImageProviderBase::Texture3图像提供程序提供基于QSGTextureProvider 的图像。所有图像请求都将调用QQuickImageProvider::requestTexture() 方法。
QQmlImageProviderBase::ImageResponse4图像提供程序提供基于QQuickTextureFactory 的图像。只能在QQuickAsyncImageProvider 或其子类中使用。所有图像请求都将调用QQuickAsyncImageProvider::requestImageResponse() 方法。自 Qt 5.6 起

成员函数文档

[pure virtual] QQmlImageProviderBase::Flags QQmlImageProviderBase::flags() const

执行此操作可返回此图像提供程序的属性。

[pure virtual] QQmlImageProviderBase::ImageType QQmlImageProviderBase::imageType() const

执行此方法可返回此图像提供程序支持的图像类型。

© 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.