title: Starting QProcess inside a thread
body: <p>I have been struggling with this basic problem for a while now.
  I’m trying to start a <code>QProcess</code> from a thread. Starting the process works fine and the process runs correctly but my problem is that the <code>finished()</code> signal is never emitted.</p>
  
  <p>Here is my example:</p>
  
  <p>My class variables are </p>
  
  <pre><code>std::atomic&lt;bool&gt;  recording;
  QProcess proc;
  std::unique_ptr&lt;std::thread&gt; recordingThread;
  </code></pre>
  
  <p>The class:</p>
  
  <pre><code>Recorder::Recorder(ParentClass *parent): QObject(parent){
  
      connect(&amp;proc,SIGNAL(finished(int)),this,SLOT(finishedFFMPEG())); 
  }
  
  void Recorder::start(){
  
      if (!recordingThread){
          recording = true;
          recordingThread.reset(new std::thread(&amp;Recorder::recordThread, this));
      }
  }
  
  void Recorder::recordThread(){
  
      while(recording){
          //writing frame
      }
      proc.start("C:\\ffmpeg.exe", QStringList() &lt;&lt;"-i"&lt;&lt; picDir.c_str() &lt;&lt; "-r"&lt;&lt; "30" &lt;&lt; "-vcodec"&lt;&lt; "ffv1" &lt;&lt; filename.c_str());
      proc.waitForStarted();      
  }
  
  void Recorder::stop(){
  
      if (recordingThread) {
          recording = false;
          recordingThread-&gt;join(); recordingThread.reset();  
      }
  }
  
  void Recorder::finishedFFMPEG(){
      qDebug() &lt;&lt; "finished";
  }
  </code></pre>
  
  <p><code>start()</code> and <code>stop()</code> are called from another non-GUI thread in my <code>ParentClass</code>.</p>
  
  <p>I tried everything from using pointers, running my <code>recordThread()</code> as a <code>QThread</code> and starting the <code>QProcess</code> in the <code>stop()</code> function but I simply never receive the <code>finished()</code> signal from the process. The process itself is being executed correctly. I know the problem lies in the different event loops.</p>
  
  <p>How can I achieve my goal of starting a process after the <code>recordThread()</code> finishes and catching the <code>QProcess</code> <code>finished()</code> signal?</p>