title: Inserting an integer into QByteArray
body: <p>I am trying to read a binary data file using QDataStream and QByteArray, make some changes, and save off as a new file.</p>
  
  <p>I have the following:</p>
  
  <pre><code>QDataStream in_datastream(&amp;file);
  QByteArray fileByteArray = file.readAll();
  //find my insertion point
  int pos = fileByteArray.indexOf(magic_num, 0);
  
  //move to insertion point, minus 4 bytes (size of an integer)
  file.seek(pos-4);
  int current_val;
  //check what the value is here
  in_datastream &gt;&gt; current_val;
  
  //now, I want to replace that value..but how?
  </code></pre>
  
  <p>I have tried several things at this point, but can't seem to figure out how to make it work. I want to insert the integer 5000 at (pos-4) in the QByteArray.</p>
  
  <pre><code>//remove 4 bytes..this seems to work
  fileByteArray.remove(pos-4, 4);
  //actually inserts garbage.
  fileByteArray.insert(pos-4, newInteger);
  </code></pre>
  
  <p>If I try to insert a 4 character string "TEST", they all get inserted properly. I think I am having some type conversion problems trying to put an integer in there.</p>