title: When or how to delete QThread in Qt
body: <p>I found this QThread example from <a href="http://qt-project.org/doc/note_revisions/5/8/view" rel="noreferrer">here</a>. It recommends to use QObject and QThread over than subclassing QThread.</p>
  
  <pre><code>class Worker : public QObject
  {
     Q_OBJECT
  
  public slots:
      void doWork() {
          /* ... */
      }
  };
  
  QThread *thread = new QThread;
  Worker *worker = new Worker;
  worker-&gt;moveToThread(thread);
  thread-&gt;start();
  QMetaObject::invokeMethod(worker, "doWork", Qt::QueuedConnection);
  </code></pre>
  
  <p>My first question is when and how to delete the thread?</p>
  
  <p>I have tried to connect finished to 2 slots, myTest and deleteLater. And I set a breakpoint in myTest, this never got triggered. So I suspect there is no finished signal, which mean the thread would not be deleted.</p>
  
  <pre><code>connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
  connect(thread, SIGNAL(finished()), this, SLOT(myTest()));
  </code></pre>
  
  <p>For the worker object, I emit a finished signal as the last instruction in doWork, and connect it to a slot in which I can delete the worker object. Is this the right way?</p>
  
  <p>Qt version: 4.6.2</p>