title: Qt: Saving an image in intended compression format
body: <p>I am using <code>Qt</code> and saving a image file out of a <code>QML</code> UI item. Following is what I do</p>
  
  <pre><code>auto screenshot = quick_item-&gt;grabToImage();
  screenshot-&gt;saveToFile("/somepath/filename.jpeg");
  // OR sometimes use like png like
  screenshot-&gt;saveToFile("/somepath/filename.png");
  </code></pre>
  
  <p>This is works fantastically well on all platforms. I open the file the image is saved as intended.</p>
  
  <p><strong>Now my question is:</strong><br>
  I just mentioned <code>.jpeg</code> as file extension while providing the filename as param into <code>saveToFile</code>. This works but, should I need to use <code>QImageWriter</code> to ensure that the image is actually compressed in <code>jpeg</code>/<code>png</code> format ?</p>
  
  <p>What happens when it is a lossy compression like <code>jpeg</code>?<br>
  How to control a lossy compression if I want to like in android I can do a <code>image.compress(CompressFormat.JPEG, 80, stream)</code> where 80 is the <a href="https://developer.android.com/reference/android/graphics/Bitmap.html" rel="nofollow noreferrer">percentage of quality for Compress</a> ?</p>