QQuickItemGrabResult Class
QQuickItemGrabResult 包含来自QQuickItem::grabToImage() 的结果。更多
头文件: | #include <QQuickItemGrabResult> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Quick) target_link_libraries(mytarget PRIVATE Qt6::Quick) |
qmake: | QT += quick |
在 QML 中: | ItemGrabResult |
继承: | QObject |
属性
公共功能
QImage | image() const |
bool | saveToFile(const QString &fileName) const |
(since 6.2) bool | saveToFile(const QUrl &filePath) const |
QUrl | url() const |
信号
void | ready() |
另请参见 QQuickItem::grabToImage().
属性文档
[read-only]
image : const QImage
该属性保存抓取的像素结果。
如果抓取尚未完成或抓取失败,则返回空图像(image.isNull()
将返回true
)。
访问功能:
QImage | image() const |
[read-only]
url : const QUrl
该属性包含一个 URL,可与基于 URL 的图像消费者(如 QtQuick::Image 类型)结合使用。
URL 在QQuickItemGrabResult 对象被删除前一直有效。
URL 并不代表一个有效的文件或读取位置,它主要是通过Qt Quick'基于图像的类型访问图像的密钥。
访问函数:
QUrl | url() const |
成员函数文档
[signal]
void QQuickItemGrabResult::ready()
抓取完成后会发出该信号。
[invokable]
bool QQuickItemGrabResult::saveToFile(const QString &fileName) const
将抓取结果作为图像保存到fileName 。如果成功,则返回true
;否则返回false
。
注: 在 5.9 之前的 Qt 版本中,此函数被标记为非const
。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable, since 6.2]
bool QQuickItemGrabResult::saveToFile(const QUrl &filePath) const
将抓取结果以图片形式保存到filePath ,该图片必须指向带有supported image format 扩展名的local file name 。如果成功,则返回true
;否则返回false
。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
此函数在 Qt 6.2 中引入。
© 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.