Set image for qml camera from c++



  • Hi,
    I convert image of camera to base64 string.

    QFile fileImg(url of image); // == camera.imageCapture.capturedImagePath
            fileImg.open(QIODevice::ReadOnly);
            QByteArray imageData = fileImg.readAll();
            QByteArray imageData_Base64 = imageData.toBase64();
            xmlWriter.writeAttribute("image",imageData_Base64);
    

    I have a string like this:
    /9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAA ......

    Now I want show above string as image in qml camera.

    Please guide me.


  • Lifetime Qt Champion

    Hi,

    Do you mean you would like to show the preview of the image you captured ?



  • @SGaist

    Thank you, my problem solved by adding "data:image/png;base64" to the beginning of encode image.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.