2

我一直在尝试将用于解码 QR 码的现有 Qt 4.x 项目转换为 Qt 5.0 QML 插件。到目前为止,移植的代码已构建,但在尝试使用它时,我偶然发现了一个问题。

C++ 端

我在将图像组件传递给插件时遇到问题。本质上,这个转换总是失败返回 0

QGraphicsObject *item = qobject_cast<QGraphicsObject*>(imageObj);

QML 端

作为参考,在 QML 方面,我实际上是将 Image ( qrcode) 传递给 C++ 插件:

decoder.decodeImageQML(qrcode); 

在哪里decoder

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++ 知识相当有限,所以我希望我遗漏了一些明显的东西,专家可以给我一个关于我做错了什么的提示。

4

0 回答 0