title: QThread : how to stop an infinite loop
body: <p>I execute in a Qthread an image processing procedure taking around 3 hours without the possibility to put some check points inside it for a exit gate. The problem is I cannot stop it. This code represents this problem :</p>
  
  <pre><code>class Toto : public QObject
  {
      Q_OBJECT
      public slots:
      void exec(){      
          //I represent the real process  with an infinite loop
          while(1==1);
      }
  };
  int main(int argc, char *argv[])
  {
      QApplication aa(argc, argv);
      QThread * t1 = new QThread;
      Toto * toto1 = new Toto;
      QThread * t2 = new QThread;
      Toto * toto2 = new Toto;
      QPushButton push;
      push.show();
      toto1-&gt;moveToThread(t1);
      toto2-&gt;moveToThread(t2);
      QMetaObject::invokeMethod(toto1, "exec", Qt::QueuedConnection);
      QMetaObject::invokeMethod(toto2, "exec", Qt::QueuedConnection);
      QApplication::connect(&amp;push, SIGNAL(pressed()), t1,SLOT(terminate()), Qt::QueuedConnection);
      QApplication::connect(&amp;push, SIGNAL(pressed ()), t2,SLOT(terminate()), Qt::QueuedConnection);
      t2-&gt;start();
      t1-&gt;start();
      return aa.exec();
  }
  </code></pre>
  
  <p>Thanks for your help</p>