Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get a picture from QString in Qt
Forum Updated to NodeBB v4.3 + New Features

How to get a picture from QString in Qt

Scheduled Pinned Locked Moved Solved General and Desktop
23 Posts 6 Posters 2.9k Views 3 Watching
  • 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #21

    I don't see how it will help to write QByteArray to json. Again, I can write Qstring to json. It remains only to learn how to safely translate from Qstring to QByteArray .

    J.HilkJ 1 Reply Last reply
    0
    • M Mikeeeeee

      I don't see how it will help to write QByteArray to json. Again, I can write Qstring to json. It remains only to learn how to safely translate from Qstring to QByteArray .

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #22

      @mikeeeeee do you actually want a qbytearray as a value to a key inside your son file ?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #23

        So it turns QString into a picture to translate

        QString AppCore::getImage(QString addressFile)
        {
            QImage myImage(addressFile);
        
            QByteArray bArray;
            QBuffer buffer(&bArray);
            buffer.open(QIODevice::WriteOnly);
            myImage.save(&buffer, "JPEG");
        
            QString image("data:image/jpg;base64,");
            image.append(QString::fromLatin1(bArray.toBase64().data()));
        
            QImage testImage(image);
            qDebug()<<"myImage.size() : "<<myImage.size();
        
            return 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