title: Qt: qthread destroyed while thread is still running during closing
body: <p>I have a class:</p>
  
  <pre><code>class centralDataPool : public QObject
  {
      Q_OBJECT
  public:
      centralDataPool(QObject * parent = 0);
      ~centralDataPool();
      commMonitor commOverWatch;
  
  private:
      QThread monitorThread;
      int totalNum;
  
  signals:
      void createMonitor(int);
  };
  </code></pre>
  
  <p>In its constructor I did:</p>
  
  <pre><code>centralDataPool::centralDataPool(QObject* parent) : QObject(parent),totalNum(0)
  {
      connect(this, SIGNAL(createMonitor(int)), &amp;commOverWatch, SLOT(createMonitor(int)));
      commOverWatch.moveToThread(&amp;monitorThread);
      monitorThread.start();
  }
  </code></pre>
  
  <p>when I called the destructor of this class I get the error message:</p>
  
  <pre><code>qthread destroyed while thread is still running
  </code></pre>
  
  <p>But when I tried to terminate the monitorThread in the destructor of class centralDataPool,</p>
  
  <pre><code>centralDataPool::~centralDataPool()
  {
      monitorThread.terminate();
  }
  </code></pre>
  
  <p>I get memory leakage.</p>
  
  <p>What is the correct way to terminate a thread during the destruction of its owner object ?</p>