title: How to save a QPixmap Object to a file?
body: <p>I'm having trouble reading and writing QByteArray data to a file. </p>
  
  <p>My goal is to save QPixmap data into a QByteArray and save that QByteArray to a file (with the ability to read this QByteArray back from the file and into a QPixmap). I want to use following code from the QPixmap documentation:</p>
  
  <pre><code>     QPixmap pixmap(&lt;image path&gt;);  
       QByteArray bytes;
       QBuffer buffer(&amp;bytes);
       buffer.open(QIODevice::WriteOnly);
       pixmap.save(&amp;buffer, "PNG"); // writes pixmap into bytes in PNG format
  </code></pre>
  
  <p>After writing the buffer to a file, I want to be able to retrieve the QByteArray and load it back into a QPixmap using the QPixmap::loadFromData() function.</p>
  
  <p>Please let me know if any further clarification is needed (I'm open to alternative approaches as well, I just need to be able to read and write the QPixmap to a file! :) );</p>