Hi,

I am trying to figure out how to emit a signal from one my threads to another thread, both non-gui threads. I see in the Qt documentation it is possible, I just cannot figure it out.

Seems like I need something like, I am just not sure in the NetReceive class.
connect(this, SIGNAL(checkNetQueue()), <ptr to other thread>, SLOT(processNetQueue()), Qt::QueuedConnection);

Here is a little background on how my classes are setup:
NetworkThread is a abstract parent class and I have two children from that thread, NetThread and NetReceiveThread. I want NetReceiveThread to emit a signal to the NetThread. If I emit the signal from NetThread itself, the slot executes and works fine.

The threads are created in my Main GUI window as class variables, like NetThread t1, NetReceiveThread t2. And then start() is called on each of them inside the MainWin constructor.

Any ideas you can come up? I appreciate the help.

Thanks so much.
RishiD

---------------------------------------------------------------------

Here are some small snippets of my three thread headers.

NetworkThread.h
Qt Code:
  1. class NetworkThread : public QThread
  2. {
  3. Q_OBJECT
  4. public:
  5. NetworkThread() { };
  6. signals:
  7. void checkNetQueue();
  8.  
  9. };
To copy to clipboard, switch view to plain text mode 

NetThread.h
Qt Code:
  1. class NetThread : public NetworkThread
  2. {
  3. Q_OBJECT
  4. public:
  5. NetThread();
  6.  
  7. protected:
  8. void run()
  9. {
  10. // emitting checkNetQueue() works fine, if the emit is run inside the NetThread
  11. connect(this, SIGNAL(checkNetQueue()), this, SLOT(processNetQueue()));
  12. exec();
  13. }
  14.  
  15. private slots:
  16. void processNetQueue();
  17. }
To copy to clipboard, switch view to plain text mode 

NetReceiveThread.h
Qt Code:
  1. class NetReceiveThread : public NetworkThread
  2. {
  3. Q_OBJECT
  4. public:
  5. NetReceiveThread(){}
  6. protected:
  7. void run()
  8. {
  9. // need to change the second this, to a pointer to NetThread
  10. // connect(this, SIGNAL(checkNetQueue()), this, SLOT(processNetQueue()),
  11. // Qt::QueuedConnection);
  12. receiveLoop() // <--- calls emit checkNetQueue();
  13. }
  14.  
  15.  
  16. };
To copy to clipboard, switch view to plain text mode