I want to fire a signal to an Object that moved into a QThread, it doesn't receive fired "startFlash" signal. Below is my code:

Qt Code:
  1. //mainwindow.cpp
  2. .....
  3. ThreadFlasher = new QThread;
  4. flasher = new Flasher(0);
  5. .....
  6. connect(ThreadFlasher, SIGNAL(started()), flasher, SLOT(process())); // This works, process function in flasher runs
  7. connect(this, SIGNAL(stopThread()), flasher, SLOT(stopThread()));
  8. connect(this, SIGNAL(startFlash()), flasher, SLOT(startFlash()));
  9. ...
  10.  
  11. void MainWindow::on_pushButtonFW_clicked()
  12. {
  13. emit startFlash();
  14. }
  15. void MainWindow::on_openButtonConnect_clicked()
  16. {
  17. flasher->moveToThread(ThreadFlasher);
  18. ThreadFlasher->start();
  19. }
  20.  
  21.  
  22. ....
  23. //Flasher.cpp
  24.  
  25. void Flasher::process()
  26. {
  27. while(run)
  28. {
  29. msleep(10); // I think There is not enough time to get variable startFlashing?
  30. if(startFlashing)
  31. {
  32. FLASH_StartFlash();
  33. startFlashing = false;
  34. }
  35. }
  36. emit finished();
  37. }
  38.  
  39. void Flasher::startFlash()
  40. {
  41. startFlashing = true;
  42. }
  43. void Flasher::stopThread()
  44. {
  45. run = false;
  46. }
To copy to clipboard, switch view to plain text mode