title: How to store a QPixmap in JSON, via QByteArray?
body: <p>I have a <code>QByteArray</code>, which I want to save in a JSON file using Qt and also be able to read from it again. Since JSON natively can't store raw data, I think the best way would probably be a string? The goal is to save a QPixmap this way:</p>
  
  <pre><code>{
    "format" : "jpg",
    "data" : "...jibberish..."
  }
  </code></pre>
  
  <p>How do I achieve this and how do I read from this JSON Object again (I am using Qt5)? What I have right now looks this way:</p>
  
  <pre><code>QPixmap p;
  ...
  
  QByteArray ba;
  QBuffer buffer(&amp;ba);
  
  buffer.open(QIODevice::WriteOnly);
  p.save(&amp;buffer, "jpg");
  
  QJsonObject json;
  gameObject["data"] = QString(buffer.data());
  
  QJsonDocument doc(json);
  file.write(doc.toJson());
  </code></pre>
  
  <p>But the resulting 'jibberish' is way to short to contain the whole image.</p>