title: C++/Qt download file in sync
body: <p>I want to achieve to download a file in a separate thread and store that file,
  but I was not able to find an appropriate way to achieve this without evil delay (quite frequent download of small files, so signal+slots are too slow).
  What I want to achieve:
  (Pseudo Code)</p>
  
  <pre><code>request file;
  wait for download finishing, timeout or error;
  save downloaded file;
  </code></pre>
  
  <p>I'd prefer an example with QNetworkAccessManager if possible.
  Thanks for any tipp.</p>
  
  <p>Edit: Just to be clear, I want signal and slots not because of design aswell as the lack of speed.</p>
  
  <p>Edit2: This download is only about the download file in sync part, threading is no problem.
  The problem is that QT does not provide an api for doing that and I am not keen on hotspinning wait.</p>
  
  <p>Edit3: Example code like it should work, but does not:</p>
  
  <pre><code>QNetworkAccessManager net;
  QNetworkReply *re (net.get( QNetworkRequest( QUrl( Qstring("www.blah.org/key") ) ) ));
  if (re-&gt;waitForReadyRead(-1)) //! @bug this does not work as supposed, waitForRead returns false and returns INSTANTLY!!
      qDebug() &lt;&lt; "ReadyRead yeha!!!";
  if (re-&gt;error()) {
      qDebug() &lt;&lt; "Can't download" &lt;&lt; re-&gt;url().toString()
              &lt;&lt; ":" &lt;&lt; re-&gt;errorString();
  } else {
      img-&gt;load(re-&gt;readAll());
      qDebug() &lt;&lt; "Savin IMG";
  }
  delete re;
  </code></pre>