title: How to check that QImage::save() has finished writing to disk?
body: <p>I have a program where I am now saving large, 18 megapixel or less images to the disk. Along the way I convert them to a QImage, display the QImage in a subclass of a QDialog, and then prompt the user to save them.</p>
  
  <p>I wanted to have some sort of progress indicator for the user, so I reasoned out that my best way to achieve that would be to create a QThread, save the image with a worker within the thread, and then emit a signal back to the GUI to declare that saving has finished. I use this method to show a progress bar to the user during the saving process.</p>
  
  <p>Consider this simple worker class here:</p>
  
  <pre><code>class Worker : public QObject
  {
      Q_OBJECT
  
  public slots:
      void doWork(const QImage &amp;image, const QString &amp;file) {
  
          if(image.save(file, "PNG", 100))
              emit resultReady();
          else
          {
              // handle error
              return;
          }
      }
  
  signals:
      void resultReady();
  };
  </code></pre>
  
  <p>My problem is that the image::save() function returns <code>true</code> often long before the image has actually finished writing to the disk. With this current line of code, on my 5600 HDD, the <code>resultReady()</code> signal is fired roughly 6 seconds after the user presses the button, and thus my GUI updates to show that the image has finished saving.</p>
  
  <p>However, the QImage seems to take anywhere from 7ish seconds to up to 30ish seconds to finish writing to disk. During this time, the user could have ended the application, which causes an incomplete image on the disk as the thread considers itself to be finished. Perhaps worse still, the user could have gone on to take multiple other images that begin to exacerbate the duration spent saving images.</p>
  
  <p>Is there a way to determine exactly when a Qt application has finished writing a QImage to the hard disk?</p>