You don't need a separate thread for that... you can do this all in one thread. If you want to "call" methods of a separate thread from the "main" thread, it involves synchronisation between those two. You can use signals & slots for that and then it is as easy as connecting them and emitting a signal. But remember that it is all an event driven mechanism and two threads don't wait for each other here...

Some small partial example (this is not a Newbie section, so I expect you can fill the rest).
Qt Code:
  1. class MyThread : public QThread{
  2. public:
  3. void run(){
  4. QTcpSocket *sock = new QTcpSocket;
  5. connect(this, SIGNAL(sendToSocket(...)), sock, SLOT(...)));
  6. // ...
  7. exec();
  8. }
  9. // ...
  10. };
  11.  
  12. MyThread *thr1;
  13. //...
  14. connect(thr1, SIGNAL(messageReceived(...)), this, SLOT(onMessageReceived(...)));
  15. connect(this, SIGNAL(sendToThread(...)), thr1, SIGNAL(SendToSocket(...)));
  16. thr1->start();
To copy to clipboard, switch view to plain text mode