Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Set image for qml camera from c++
Forum Update on Monday, May 27th 2025

Set image for qml camera from c++

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neda
    wrote on last edited by neda
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      N 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

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

        N Offline
        N Offline
        neda
        wrote on last edited by
        #3

        @SGaist

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved