Qt/QML : Send QImage From C++ to QML and Display The QImage On GUI

后端 未结 4 910
执念已碎
执念已碎 2020-12-23 11:34

I created a class Publisher which periodically emits a QImage object.

However I\'m having a tough time drawing the QImage to

4条回答
  •  粉色の甜心
    2020-12-23 12:11

    QString getImage()
    {
    QByteArray byteArray;
    QBuffer buffer(&byteArray);
    buffer.open(QIODevice::WriteOnly);
    img.save(&buffer,"JPEG");
     //save image data in string
    QString image("data:image/jpg;base64,");
    image.append(QString::fromLatin1(byteArray.toBase64().data()));
    return image;
    }
    
    

    send image string directly to qml source

提交回复
热议问题