***********************logon.cpp********************/
....
if(...){
next.show();
this->hide();
emit sendTcp(&tcpClient);
}
....
/***********************next.cpp*********************/
{
........
//sendTcp 信号是从登录界面发送的。
connect(this,SIGNAL(sendTcp(QTcpSocket *)),this,SLOT(reciveTcp(QTcpSocket *)));
}
void Teste::reciveTcp(QTcpSocket *tcpClient){
qDebug()<<"tcpClient hostname is"<<tcpClient->peerAddress()<<"host is-->"<<tcpClient->peerPort();
client = tcpClient;
qDebug()<<"tcpClient hostname is"<<client->peerAddress()<<"host is-->"<<client->peerPort();
connect(client,SIGNAL(readyRead()),this,SLOT(readyread()));
connect(client, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(displayError(QAbstractSocket::SocketError)));
}