Hello,

Is it possible signal emited from the main(or other) thread to be received in a slot inside the QThread context? I have failed to accomplish that so far...

Here's what I'm basically doing:
Qt Code:
  1. class MyThread : QThread
  2. {
  3. Q_OBJECT:
  4.  
  5. public:
  6. MyThread() {}
  7. ~MyThread() {}
  8.  
  9. void addNewStuff()
  10. {
  11. // This method is called from the main thread
  12. emit newStuff();
  13. }
  14.  
  15. protected:
  16. virtual void run()
  17. {
  18. connect( this, SIGNAL(newStuff()), this, SLOT(onNewStuff()) );
  19. exec();
  20. }
  21.  
  22. private slots:
  23. void onNewStuff()
  24. {
  25. // My slot also is called from the main thread... :(
  26. QThread::currentThreadId();
  27. }
  28.  
  29. signals:
  30. void newStuff();
  31. };
To copy to clipboard, switch view to plain text mode 

MyThread is created and started from the main thread. At some point the main thread will call addNewStuff() method which I'm expecting to call onNewStuff() in the MyThread context, not in the main thread's one. So far my slot is always called from the main thread context... I also tried changing the flags of the connect() method but with no luck.

Any help will be appreciated.