线程TcpThread的run函数如下所示
void TcpThread::run()
{
tcpClient=new QTcpSocket();
timer.start();
timer.setInterval(reConInterval);
connect(&timer,SIGNAL(timeout()),this,SLOT(connSrv()));
connect(tcpClient,SIGNAL(connected()),this,SLOT(sendMsg()));
connect(tcpClient, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(operateError(QAbstractSocket::SocketError)));
//connect(tcpClient,SIGNAL(disconnected()),&timer,SLOT(stop()));
connect(tcpClient,SIGNAL(readyRead()),this,SLOT(recvMsg()));
exec();
//delete tcpClient;
}
结果总是提示,QObject: Cannot create children for a parent that is in a different thread.
上网查了很多资料,始终不知道如何修改,请高手指教