Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to encode an image to base64?
Qt 6.12 LTS is out! See what's new in the release blog

How to encode an image to base64?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 542 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.
  • Z Offline
    Z Offline
    zeroalpha
    wrote on last edited by
    #1

    Hello everyone :)

    How is it possible to capture an image in qml and then encode it to base64?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mohammad Sherafat
      wrote on last edited by Mohammad Sherafat
      #2

      Thanks,
      I also tried this but doesn't work:

      QFile file("/home/user/cat.png");
      if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
              return QImage();
      
      QByteArray content = file.readAll();
      
      QImage::fromData(content.toBase64(QByteArray::Base64Encoding), "PNG");
      
      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
      • Unsolved