title: Convert std::vector<uint8_t> to QImage
body: <p>I am trying to create QImage from std::vector. I tried; </p>
  
  <pre><code>void FaceCutThread::convertImage(std::vector&lt;uint8_t&gt; &amp;buf)
  {
      QImage img(&amp;buf[0], 300, 300, QImage::Format_ARGB32);
  
      emit isFinisedFaceCut(img);
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>void FaceCutThread::convertImage(std::vector&lt;uint8_t&gt; &amp;buf)
  {
      QImage img(buf.data(), 300, 300, QImage::Format_ARGB32);
  
      emit isFinisedFaceCut(img);
  }
  </code></pre>
  
  <p>both two type of convertion didn't give any error;however, when I tried to show it in <code>QLabel</code> like; </p>
  
  <pre><code>void MainWindow::handleFaceResults(QImage&amp; buf)
  {
      QImage myImage(buf);
      ui-&gt;lblRawImage-&gt;setPixmap(QPixmap::fromImage(myImage));
  }
  </code></pre>
  
  <p>my app always unexpectedly finishing. Could you please help how I can convert to QImage correctly?</p>
  
  <p>EDIT: </p>
  
  <p>I can write image into file without any problem like; </p>
  
  <pre><code>bool save_file (const string &amp;path, const vector&lt;uint8_t&gt; &amp;data)
  {
      std::ofstream os;
      os.open(path.c_str(), std::ios::out | std::ios::binary);
      if (!os.is_open())
          return false;
  
      os.write((const char*)data.data(), data.size());
      return true;
  }
  </code></pre>