how connect() function behave differently in movetothread
JadeN001 last edited by
I used moveToThread() to move the worker object ,in which i'm doing setSocketDescripter, and I have connected two connection readyRead and disconnect in worker class. Rest of the connections are there in the server class. and the code is working fine.
I have created a Qvector of QTcpSockets in server class which is global.
Now if I move one connection from server class to the worker class, the size of the vector becomes zero.
in worker class ::
connect(this,SIGNAL(aboutToWrite(QByteArray, QTcpSocket *)),S,SLOT(messageFromclient(QByteArray, QTcpSocket *)));
in server class::
connect(worker,SIGNAL(aboutToWrite(QByteArray, QTcpSocket *)),this,SLOT(messageFromclient(QByteArray, QTcpSocket *)));
in messageFromClient() slot , i'm sending messages to all the sockets connected but when I move this connection to worker class , the vector size becomes zero even if there are multiple clients connected.
MokJ last edited by
I think the connection should be done outside the worker class , as worker class will only be called when its required.
Can you show your actual code ?