title: How to read stdout/stderr from detached QProcess
body: <p>I am a total beginner in Qt. I need to call a command-line program from a button in my desktop app. The program downloads a YouTube video. I also need to read standard error from it. I wrote the following code:</p>
  
  <pre><code>void YoutubeDL::on_downloadButton_clicked()
  {
      [...]
  
      QProcess p;
      p.startDetached("youtube-dl -f " + get + " " + ui-&gt;urlBox-&gt;text());
      QString perr = p.readAllStandardError();
      if (perr.length())
          ui-&gt;descBox-&gt;setText("Error during download.\n" + perr);
      else
          ui-&gt;descBox-&gt;setText("Download completed!");
  }
  </code></pre>
  
  <p>However the stderr read does not take place. </p>
  
  <p>On the other hand if I use non-detached <code>p.start()</code> and then <code>waitForFinished(-1)</code> then I can read the stderr, but the GUI freezes until the download completes.</p>
  
  <p>How can this be fixed?</p>
  
  <p><strong>A related problem:</strong> I would also like some way to be able to read the outputs of the download process in real-time, so that I can display it in the GUI. youtube-dl gives progress reports like this:</p>
  
  <pre><code>[download]   0.0% of 2.00MiB at 173.22KiB/s ETA 00:12
  [download]   0.1% of 2.00MiB at 105.01KiB/s ETA 00:19
  [download]   0.3% of 2.00MiB at 96.86KiB/s ETA 00:21
  [download]   0.7% of 2.00MiB at 105.23KiB/s ETA 00:19
  [download]   1.5% of 2.00MiB at 100.29KiB/s ETA 00:20
  ...
  </code></pre>
  
  <p>I'd like to be able to read these as and when they are generated.</p>