title: QByteArray to unsigned char does not fully copy
body: <p>I need to convert the QByteArray of a QImage into unsigned char *.</p>
  <p>I do it by:</p>
  <pre><code>QByteArray data;
  QBuffer buffer(&amp;data);
  
  buffer.open(QIODevice::WriteOnly);
  convImage.save(&amp;buffer, &quot;PNG&quot;);
  buffer.close()
  
  unsigned char *data_image = (unsigned char *)malloc(data.size());
  memcpy(data_image, reinterpret_cast&lt;unsigned char *&gt;(data.data()), (unsigned int)data.size());
  </code></pre>
  <p>But the result of data_image compared to the QByteArray of the image is like this:</p>
  <p><a href="https://i.stack.imgur.com/4827l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4827l.png" alt="enter image description here" /></a></p>
  <blockquote>
  <p>data = (QByteArray of the Image)</p>
  <p>data_image = unsigned char* from data</p>
  </blockquote>
  <p>I think it's not fully copied. I need the unsigned char* data for an external DLL function.</p>