title: Reading unsigned short array using Qt in C++
body: <p>I'm trying to read an array of unsigned shorts using the Qt API. Unfortunately, I'm not getting the desired results.</p>
  
  <p>The following code</p>
  
  <pre><code>        QFile in(fileName);
          int len = in.size();
          QDataStream d(&amp;in);
  
          quint16 *data = new quint16[len];
          qDebug() &lt;&lt; data[0];
          qDebug() &lt;&lt; data[1];
          d &gt;&gt; data[0];
          qDebug() &lt;&lt; data[0];
          qDebug() &lt;&lt; data[1];
  </code></pre>
  
  <p>outputs</p>
  
  <pre><code>         52685 
           52685 
           13109 
           52685 
  </code></pre>
  
  <p>Implying that the data is only changed at the first array position. Also, I always thought that arrays are zero initialized? Using a <code>QByteArray</code> doesn't seem to work here, that's why I'm trying to use a array of <code>quint16</code> (= unsigned shorts). Using a loop may be an option, but I'm trying to avoid a costly loop where ever possible.</p>
  
  <p>So, how do fill said array (data) with the desired data from the file? Is it possible to carry the data using a <code>QByteArray</code>?</p>