title: QThread - Using a slot quit() to exit the thread
body: <p>I want to inform an object when a thread has finished running. However, I cannot get the thread to exit properly. I have the following code:</p>
  
  <p>Processor.cpp</p>
  
  <pre><code>thread = new QThread;
  tw = new ThreadWorker;
  connect(tw, SIGNAL(updateStatus(QString)), this, SLOT(statusUpdate(QString)));
  tw-&gt;doSetup(thread, strDic);
  tw-&gt;moveToThread(thread);
  thread-&gt;start();
  
  while(thread-&gt;isRunning())
  {
  }
  
  qDebug() &lt;&lt; "Thread Finished";
  </code></pre>
  
  <p>ThreadWorker.cpp</p>
  
  <pre><code>void ThreadWorker::doSetup(QThread *thread, const string &amp;path)
  {
    _strPath = path;
    connect(thread, SIGNAL(started()), this, SLOT(run()));
    connect(this, SIGNAL(finished()), thread, SLOT(quit())); //tried terminate() also
  }
  
  
  void ThreadWorker::run()
  {
    DirectorySearch dicSearch;
    vector&lt;string&gt; vecFileList = dicSearch.getFileList(_strPath);
    emit updateStatus("Directory Fetched");
    emit finished();
  }
  </code></pre>
  
  <p>The quit() slot does not seem to stop the thread (QThread::isFinished never returns true). Can someone guide me in the right direction?</p>
  
  <p>(Note: ThreadWorker does not inherit from QThread)</p>