title: Stop QThread to execute
body: <p>I am trying to implement timeout in my QT Application. I have used QThread to perform the operation (task on which timeout is required) and have used QElapsedTimer to count elapsed time waiting to perform the operation. Below is the code snippet</p>
  
  <pre><code>QElapsedTimer timeoutTimer;   // Timer to count the elapsed time waiting for the operation to complete.
  long timeoutInterval=10000
  MyThread mThread();   // QThread implementation
  timeoutTimer.start(); 
  mThread.start();   
  
  while((timeoutTimer.elapsed() &lt; timeoutInterval) &amp;&amp;  mThread.isRunning()){
      sleep(5);
  }
  
  
  if(mThread.isRunning()){
    mThread.terminate();
  }
  </code></pre>
  
  <p>Now, if task is not completed and timeout happens I get <strong>"Destroyed while thread is still running"</strong> and application gets crashed.
  I tried to call terminate() function of QThread but it is working on Windows however on Linux I get segmentation fault.</p>