I got a problem with my threaded TCP-Server.
I can open my Server, a new Socket is created an I can receive data over the socket (I used the readyRead() signal and then
Your error message means:
Your signal-slot communication happens on ServerThread instance which was created and belongs to main thread. However instance of ServerThread member m_socket was created and belongs to other thread.
I would suggest you to create simple QThread
and move your object into it.
void Server::incomingConnection(int socketDescriptor) {
QThread *t = new QThread();
ClientConnection *client = new ClientConnection(socketDescriptor);
client->moveToThread(t);
// go
t->start();
}
class ClientConnection : public QObject {
Q_OBJECT
public:
ClientConnection(int socketDescriptor, QObject *parent = 0);
public slots:
void writeData(QString data);
private:
int m_socketDescriptor;
QTcpSocket *m_socket;
}