Quote Originally Posted by franz View Post
This means that you have to define a QObject inside the run() function; one that actually lives in another thread. Then you can use the timer to tell that QObject to doAction().
Ok, i've rewrite it, so at the moment it looks like this
Qt Code:
  1. /* Thread.h */
  2. #include <QThread>
  3.  
  4. class Object : public QObject
  5. {
  6. Q_OBJECT
  7. public:
  8. Object();
  9. protected:
  10. void timerEvent(QTimerEvent*);
  11. signals:
  12. void update(int);
  13. private:
  14. int timerId;
  15. }
  16.  
  17. class Thread : public QThread
  18. {
  19. Q_OBJECT
  20. public:
  21. Thread();
  22. void run();
  23. private:
  24. Object* object;
  25. };
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. /* Thread.cpp */
  2. #include "Thread.h"
  3.  
  4. Thread::Thread() {
  5. }
  6.  
  7. void Thread::run() {
  8. object = new Object();
  9. exec();
  10. }
  11.  
  12. Object::Object() {
  13. timerId = startTimer(1000);
  14. }
  15.  
  16. Object::~Object() {
  17. killTimer(timerId);
  18. }
  19.  
  20. void Object::timerEvent(QTimerEvent* event) {
  21. here i write some data to port and then get some data
  22. emit update(some data);
  23. }
To copy to clipboard, switch view to plain text mode 
As i understood, you advised me to create an object inside QThread::run() function and then to use a timer for this object. Unfortunately, GUI is steel freezing when this object is trying to read from port. Maybe, i've missed something?