[SOLVED] How to get readyRead signal for tcp socket on different thread SLOT
I have created a Qt GUI app, from there I have created a separate thread of execution, in the run method of the thread I have created a QTcpSocket and registered readyRead() signal with some SLOT in the same thread class.
My prob is GUI thread is calling this SLOT everytime , I am expecting SLOT should be get called from the worker thread, otherwise there is no use of using the separate thread of execution.
Note :- I have tried to create the socket both the way using heap and stack of the worker thread.
You’re doing it wrong™. Subclassing QThread is no longer the recommended way of implementing multithreading in Qt. Please have a look at the Threads, Events and QObjects wiki article for details of the now recommended way.
I have got this code snippet from the above mentioned link.
I don’t understand what the obj is here?
How I will signal to do some job inside Worker class.
My problem scenario is mentioned below:-
I wanted to have one QObject derived class there , I will be having one QWebView. From this class I wanted to create separate thread of execution, and I wanted to create one tcpsocket and it should run in that thread class. I will be registering for readyread() and this signal should be called from that separate thread not from GUI thread.
Additionally , I waned to signal this thread class to write some data on this socket.
please suggest a cleaner approach to do this.
If you have some code snippet for writting worker threads , please share with me.
It is bit urgent
Thanks in Advance