title: (Qt C++) Write QString to file as Binary
body: <p>I am working on a project and I need to write (and in the future read) a string (QString) as binary. The string is in HEX format, like this "00010203040506070a0f01" etc...</p>
  
  <p>I got this far through a tutorial on YouTube:</p>
  
  <pre><code>void Output()
  {
      QString ye("01020a");
      QFile file("C:\\Users\\Public\\Documents\\Qt_Projects\\myfile.dat";
  
      if(!file.open(QIODevice::WriteOnly))
      {
          qDebug() &lt;&lt; "Could not open file to be written";
          return;
      }
  
      QDataStream out(&amp;file);
      out.setVersion(QDataStream::Qt_5_0);
  
      out &lt;&lt; ye;
  
      file.flush();
      file.close();
     }
  </code></pre>
  
  <p>But when I open "myfile.dat" with a hex editor, the hex values are different, the QString "ye" was written to the text side of things. </p>
  
  <pre><code>00 00 00 0C 00 30 00 31 00 30 00 32 00 30 00 61
  </code></pre>
  
  <p>Help?</p>