title: QThread - how to stop worker?
body: <p>I'm reading that I should use worker object and move it to thread by moveToThread instead of inherit from QThread directly. But I can't find solution how to stop loop in my object worker. For example I have test loop:</p>
  
  <pre><code>void CollectionWorker::doWork()
  {
      for (int i = 0; i &lt; 10; ++i) {
          sleep(1);
          emit ping(i);
      }
  }
  </code></pre>
  
  <p>Now I'm moving this object to thread: </p>
  
  <pre><code>worker-&gt;moveToThread(mTh); 
  </code></pre>
  
  <p>This is working fine. But when I call mTh.quit() then thread is waiting until loop in doWork is end. When I inherit from QThread directly then on each loop I can check thread status and break loop when thred is finished but don't know how to do it in worker object. Can I just create some flag in worker object and switch it from main thread? Or maybe can I find thread owner and check it status? Or maybe better before starting thread, set thread pointer in worker object and then check status? What is the best thread safe solution?</p>
  
  <p>Regards</p>