更新代码

This commit is contained in:
feiyangqingyun
2022-04-30 18:17:25 +08:00
parent 293a8d9c40
commit 7bed44d9c0
10 changed files with 62 additions and 58 deletions

View File

@@ -8,13 +8,13 @@ TcpClient1::TcpClient1(QObject *parent) : QTcpSocket(parent)
port = 6907;
deviceID = "SSJC00000001";
connect(this, SIGNAL(disconnected()), this, SLOT(deleteLater()));
connect(this, SIGNAL(readyRead()), this, SLOT(readData()));
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
connect(this, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(deleteLater()));
#else
connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(deleteLater()));
#endif
connect(this, SIGNAL(disconnected()), this, SLOT(deleteLater()));
connect(this, SIGNAL(readyRead()), this, SLOT(readData()));
#endif
}
void TcpClient1::setIP(const QString &ip)

View File

@@ -8,13 +8,13 @@ TcpClient2::TcpClient2(QObject *parent) : QTcpSocket(parent)
port = 6908;
deviceID = "SSJC00000001";
connect(this, SIGNAL(disconnected()), this, SLOT(deleteLater()));
connect(this, SIGNAL(readyRead()), this, SLOT(readData()));
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
connect(this, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(deleteLater()));
#else
connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(deleteLater()));
#endif
connect(this, SIGNAL(disconnected()), this, SLOT(deleteLater()));
connect(this, SIGNAL(readyRead()), this, SLOT(readData()));
}
void TcpClient2::setIP(const QString &ip)

View File

@@ -10,12 +10,12 @@ TcpClient::TcpClient(QTcpSocket *socket, QObject *parent) : QObject(parent)
port = socket->peerPort();
connect(socket, SIGNAL(disconnected()), this, SLOT(slot_disconnected()));
connect(socket, SIGNAL(readyRead()), this, SLOT(slot_readData()));
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(slot_error()));
#else
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slot_error()));
#endif
connect(socket, SIGNAL(readyRead()), this, SLOT(slot_readData()));
}
QString TcpClient::getIP() const

View File

@@ -40,12 +40,12 @@ void frmTcpClient::initForm()
socket = new QTcpSocket(this);
connect(socket, SIGNAL(connected()), this, SLOT(connected()));
connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(error()));
#else
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error()));
#endif
connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
//定时器发送数据
timer = new QTimer(this);

View File

@@ -36,12 +36,12 @@ void frmUdpClient::initForm()
//实例化对象并绑定信号槽
socket = new QUdpSocket(this);
connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(error()));
#else
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error()));
#endif
connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
#endif
//定时器发送数据
timer = new QTimer(this);

View File

@@ -37,12 +37,12 @@ void frmUdpServer::initForm()
//实例化对象并绑定信号槽
socket = new QUdpSocket(this);
connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(error()));
#else
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error()));
#endif
connect(socket, SIGNAL(readyRead()), this, SLOT(readData()));
#endif
//定时器发送数据
timer = new QTimer(this);

View File

@@ -175,7 +175,7 @@ void frmWebClient::disconnected()
{
isOk = false;
ui->btnConnect->setText("连接");
append(1, "服务器断开");
append(1, "服务器断开");
}
void frmWebClient::error()