title: How to properly delete and terminate QThread
body: <p>I have got a subclass <code>MyClass</code> which inherits from <code>QThread</code>.</p>
  
  <p>I create it like this with a parent to the <code>MainWindow</code> instance (this):</p>
  
  <pre><code>mMyClass = new MyClass("some_value", 1, 5L, this);
  </code></pre>
  
  <p>My understanding of how Qt deals with object deletion is that every <code>QObject</code>, which has a parent gets deleted when the parent gets deleted.</p>
  
  <p>If my program does finish I get a warning <code>QThread: Destroyed while thread is still running</code></p>
  
  <p>How can I fix this one up? I tried it with the following code in the deconstructor of <code>MainWindow</code>. Unfortunately it does not work properly:</p>
  
  <pre><code>if (mMyClass != 0 &amp;&amp; mMyClass-&gt;isRunning()) {
      mMyClass-&gt;deleteLater();
      mMyClass-&gt;quit();
      mMyClass-&gt;wait();
  }
  </code></pre>