I have a code like this

void Client::run()
{

tcpSocket = new QTcpSocket();

if (tcpSocket->setSocketDescriptor(socketDesc))
{

peerAdress = tcpSocket->peerAddress().toString();
peerPort = tcpSocket->peerPort();

emit connected();
}

while (!quit)
{
if (tcpSocket->waitForReadyRead(Timeout))
{
// Read data
QDataStream in(tcpSocket);
in.setVersion(QDataStream::Qt_4_0);
in >> buffer;
qDebug() << buffer<<endl;
}


}
//slot to send a message
void Client::sendMessage(QString message)
{
tcpSocket->write(message);
}


I have also sender thread gets message from message queues and send signal to thread above to write message socket.

it is implemented as below.

void Sender::run()
{

while(!quit)
{
qDebug() <<"sending message" <<endl;
emit sendMessage("message");

sleep(1);
}
}

but when code runs I get following error.

what is the problem.


QObject: Cannot create children for a parent that is in a different thread.
and
QSocketNotifier: socket notifiers cannot be disabled from another thread