Quote Originally Posted by hashb View Post
Hi tbscope,you mean the slot of the thread executed in the main thread ?




Thanks a lot for you explanation,
it was just a test in order to produce a loop
Do this with QTimer. Something like this :
Qt Code:
  1. #ifndef AAA_
  2. #define AAA_
  3. #include <QThread>
  4. #include <QString>
  5. #include <QDebug>
  6. #include <QTimer>
  7.  
  8. class myClass : public QThread
  9. {
  10. Q_OBJECT
  11. public:
  12. myClass ()
  13. {
  14. connect(&timer,
  15. SIGNAL(timeout()),
  16. this, SLOT(onDoComm()));
  17. }
  18. void run() { exec(); }
  19. void startComm() {timer.start(10);}
  20. signals:
  21. void startSignal();
  22. public slots:
  23. void onDoComm()
  24. {
  25. static long i=1;
  26. qDebug()<<str;
  27. str=QString("%1%2").arg(i++);
  28. };
  29. private:
  30. QString str;
  31. QTimer timer;
  32. };
  33. #endif
To copy to clipboard, switch view to plain text mode 
In this example onDoComm will be executed one time per 10 ms