From 999aff587b461e8bf6681f376a63c9bccc26a0a8 Mon Sep 17 00:00:00 2001 From: zjtdd Date: Sat, 12 Jan 2019 15:50:54 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9ComboBox=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BA=E6=9C=AA=E6=BF=80=E6=B4=BB=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E6=B3=95=E5=86=8D=E6=AC=A1=E8=A2=AB=E6=BF=80?= =?UTF-8?q?=E6=B4=BB=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82=202=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=BF=E7=94=A8=E8=AF=B4=E6=98=8E=E7=9A=84?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 +------ SCTcpToolWidget.cpp | 35 +++++++++++++++++++++++++++-------- SCTcpToolWidget.h | 10 +++++++++- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d87366c..0056413 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,7 @@ email: support@seer-robotics.com ## 推荐配置环境(开发时的环境) 操作系统:Win10 x64 -编程环境:QT Creator 5.9.4 MSVC14(vs2015) - -## 注意事项 -1 打开工程后,选择Release方式构建工程,否则运行之后程序将无法加载数据库。 - - +编程环境:QT Creator 5.9.4 ## 使用说明 用途:用于测试RoboKit NetProtocol TCP API,并且可通过此工具发送对应的指令实现对我司机器人的控制。 diff --git a/SCTcpToolWidget.cpp b/SCTcpToolWidget.cpp index 6a8cae7..1b157c6 100644 --- a/SCTcpToolWidget.cpp +++ b/SCTcpToolWidget.cpp @@ -262,8 +262,8 @@ void SCTcpToolWidget::stateChanged(QAbstractSocket::SocketState state) switch (state) { case QAbstractSocket::UnconnectedState: info = "QAbstractSocket::UnconnectedState"; - ui->pushButton_connectAndSend->setEnabled(true); ui->checkBox_queryTime->setEnabled(true); + ui->pushButton_connectAndSend->setEnabled(true); // qDebug() << QStringLiteral("开始连接"); ui->textEdit_info->append(QString(QStringLiteral("连接已断开!!!"))); @@ -311,7 +311,7 @@ void SCTcpToolWidget::stateChanged(QAbstractSocket::SocketState state) if (_reqFinished && !ui->checkBox_queryTime->isChecked()) { // 断开当前的连接 _reqFinished = false; - ui->textEdit_info->append(QString(QStringLiteral("指令发送完成,正在断开连接..."))); + ui->textEdit_info->append(QString(QStringLiteral("指令发送完成,断开连接"))); _pSCStatusTcp->releaseTcpSocket(); ui->checkBox_queryTime->setEnabled(true); @@ -470,13 +470,11 @@ void SCTcpToolWidget::myKillTimer(int id) void SCTcpToolWidget::on_checkBox_queryTime_clicked(bool checked) { - qDebug() << "query time"; + qDebug() << "query time" << checked; if(checked){ myConnect(); // 先建立连接 _queryTimeID = this->startTimer(ui->spinBox_queryTime->value()); - ui->comboBox_port->setEnabled(false); - ui->comboBox_sendCommand->setEnabled(false); - }else{ + }else { if (_queryTimeID > 0) { myKillTimer(_queryTimeID); resetDateTime(); @@ -484,8 +482,6 @@ void SCTcpToolWidget::on_checkBox_queryTime_clicked(bool checked) if (_reqFinished) { // 在发送完指令,并接受到响应之后再断开连接 _reqFinished = false; // 提前重置标志,防止界面上输出多有的信息 _pSCStatusTcp->releaseTcpSocket(); - ui->comboBox_port->setEnabled(true); - ui->comboBox_sendCommand->setEnabled(true); } } @@ -513,3 +509,26 @@ void SCTcpToolWidget::resetDateTime() { _dateTime = QTime(0, 0, 0, 0); } + +void SCTcpToolWidget::on_checkBox_queryTime_stateChanged(int arg1) +{ + bool enable; + qDebug() << "current state: " << arg1; + if (arg1 == 0) {// 未勾选状态 + // 激活comboBox和pushButton + enable = true; + ui->comboBox_port->setEnabled(enable); + ui->comboBox_sendCommand->setEnabled(enable); + ui->pushButton_connectAndSend->setEnabled(enable); + + // 放弃连接 + _pSCStatusTcp->releaseTcpSocket(); + + } else if (arg1 == 2) { // 勾选状态 + // 抑制comboBox和pushButton + bool enable = false; + ui->comboBox_port->setEnabled(enable); + ui->comboBox_sendCommand->setEnabled(enable); + ui->pushButton_connectAndSend->setEnabled(enable); + } +} diff --git a/SCTcpToolWidget.h b/SCTcpToolWidget.h index b7803ce..bfab4db 100644 --- a/SCTcpToolWidget.h +++ b/SCTcpToolWidget.h @@ -129,7 +129,9 @@ private slots: /** * @brief on_checkBox_timeOut_clicked - 设置超时 * @param checked - true:启用超时;false:不启用 - */ + void on_checkBox_queryTime_stateChanged(int arg1); + +*/ void on_checkBox_timeOut_clicked(bool checked); /** @@ -138,6 +140,12 @@ private slots: */ void on_checkBox_queryTime_clicked(bool checked); + /** + * @brief on_checkBox_queryTime_stateChanged - 根据是否定时发送,设置界面控件的状态 + * @param arg1 - checkBox的状态 + */ + void on_checkBox_queryTime_stateChanged(int arg1); + private: