title: How to convert QImage to QByteArray?
body: <p>I am trying to create QByteArray from QImage, however although I tried lots of varient, I couldn't handle it. </p>
  
  <p>What I am doing is : </p>
  
  <pre><code>QImage img_enrll; // &lt;--- There is an image coming from another function. 
  
  QByteArray arr((char*)img_enrll.bits(),img_enrll.byteCount());  // &lt;-- convertion but I am not sure it is true or not. 
  
  funcCheck((unsigned char*)arr.data(), arr.size(), 0, &amp;sam, 1, &amp;n);
  
  
  virtual Error funcCheck (const uint8_t    src[],
                             size_t           src_len,
                             size_t           tout_ms,
                             IRawSample*      dst[],
                             size_t           dst_len,
                             size_t*          dst_n )
  </code></pre>
  
  <p>However Error code is return Invalid Data. I think that converting QImage to QByteArray is wrong. Please could you kindly help me how to convert to QByteArray? </p>