I have a thread and a tcpSocket. The tcpSocket is declared in my "x.h" class.

At some point I want to use this tcpSocket, but I get this message:

ASSERT failure in QObject::QObject(): "Cannot create children for a parent that is in a different thread.", file kernel/qobject.cpp, line 599

This is the code where I create my tcpSocket:
Qt Code:
  1. void Client :: run()
  2. {
  3. cout << "void Client :: run()\n";
  4. tcpSocket = new QTcpSocket();
  5. if(!tcpSocket->setSocketDescriptor(socketDescriptor))
  6. {
  7. cout << "Error - tcpSocket descriptor\n";
  8. return;
  9. }
  10. connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readData()));
  11. connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
  12. exec();
  13. }
To copy to clipboard, switch view to plain text mode 

This is the code where I want my tcpSocket to write to another computer:
Qt Code:
  1. void Client :: loginResponse(bool accepted, QString *userName, QByteArray *messageOut)
  2. {
  3. if(accepted==true)
  4. {
  5. server->addClient(*userName, this);
  6. clientLogged = true;
  7. tcpSocket->write("hello\n");
  8. }
  9. }
To copy to clipboard, switch view to plain text mode 


How can i refer to the tcpSocket that was instantiated in the run() ?