C++ 如何将图像对象从QML传递到C++;插件

C++ 如何将图像对象从QML传递到C++;插件,c++,qt,qml,qt5,qtquick2,C++,Qt,Qml,Qt5,Qtquick2,我一直在尝试将现有的qt4.x项目(用于解码QR码)转换为qt5.0qml插件。到目前为止,移植的代码已经生成,但在尝试使用它时,我偶然发现了一个问题 C++侧 我在向插件传递图像组件时遇到问题。基本上: 其中,解码器是: QZXing { id: decoder onTagFound: console.log("Tag found: " + tag) onDecodingStarted: console.log("Decoding started") onDec

我一直在尝试将现有的qt4.x项目(用于解码QR码)转换为qt5.0qml插件。到目前为止,移植的代码已经生成,但在尝试使用它时,我偶然发现了一个问题

C++侧 我在向插件传递图像组件时遇到问题。基本上:

其中,
解码器
是:

QZXing {
    id: decoder
    onTagFound: console.log("Tag found: " + tag)
    onDecodingStarted: console.log("Decoding started")
    onDecodingFinished: console.log("Decoding finished " + (succeeded==true ? "successfully" : "unsuccessfully"))
}
我的Qt/C++知识相当有限,所以我希望我遗漏了一些明显的东西,专家可以告诉我我做错了什么


您是否在QML项目中使用了
QtQucik 2.0
?是的,这是一个使用QtQuick 2So的Qt 5项目。它应该是QQuickItem而不是QGraphicItem。您可能会发现很难从中获取图像,因为它的内容只能作为OpenGL纹理使用。您需要自己读取源属性并加载图像。还仅提供文件位置。
decoder.decodeImageQML(qrcode); 
QZXing {
    id: decoder
    onTagFound: console.log("Tag found: " + tag)
    onDecodingStarted: console.log("Decoding started")
    onDecodingFinished: console.log("Decoding finished " + (succeeded==true ? "successfully" : "unsuccessfully"))
}