Qt6 topics merged with General

Set image for qml camera from c++

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

    QFile fileImg(url of image); // == camera.imageCapture.capturedImagePath
            QByteArray imageData = fileImg.readAll();
            QByteArray imageData_Base64 = imageData.toBase64();

    I have a string like this:

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

    Please guide me.

  • Lifetime Qt Champion


    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