Problem is that you are doing that wrong!
Qt Code:
  1. class TestClass : QObject
  2. {
  3. Q_OBJECT
  4. public:
  5. TestClass(QObject *parent=0);
  6.  
  7. public slots:
  8. void tick();
  9. };
  10.  
  11. TestClass::TestClass(QObject *parent) : QObject(parent)
  12. {
  13. QTimer *t = new QTimer(this);
  14. connect(t, SIGNAL(timeout()), this, SLOT(tick()));
  15. }
  16.  
  17. void TestClass::tick()
  18. {
  19. qDebug() << currentThreadId() << "tick()";
  20. }
  21.  
  22. // and somewhere
  23. QThread *thread = new QThread(something);
  24. TestClass *object = new TestClass(); // can't pass parent!!!!!!
  25. object->moveToThread(thread);
  26. thread->start();
  27.  
  28. ....
  29. delete object;
  30. thread->WaitFor();
  31. // delete thread;
To copy to clipboard, switch view to plain text mode