//建立TcpSocket对象
MyTcpSocket = new QTcpSocket(this);
//信号连接
connect(MyTcpSocket, SIGNAL(connected()), this, SLOT(connected()));
connect(MyTcpSocket, SIGNAL(disconnected()), this, SLOT(DisConnected()));
connect(MyTcpSocket, SIGNAL(readyRead()), this, SLOT(readyRead()));
//本机IP
ServerIp=QHostAddress::LocalHost;
//连接服务器
MyTcpSocket->connectToHost(ServerIp, port, QIODevice::ReadWrite);