Skip to content

Commit

Permalink
1、修改ComboBox设置为未激活之后,无法再次被激活的问题。
Browse files Browse the repository at this point in the history
2、修改使用说明的内容。
  • Loading branch information
zjtdd committed Jan 12, 2019
1 parent e22bf2a commit 999aff5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ email: [email protected]
## 推荐配置环境(开发时的环境)
操作系统:Win10 x64

编程环境:QT Creator 5.9.4 MSVC14(vs2015)

## 注意事项
1 打开工程后,选择Release方式构建工程,否则运行之后程序将无法加载数据库。


编程环境:QT Creator 5.9.4

## 使用说明
用途:用于测试RoboKit NetProtocol TCP API,并且可通过此工具发送对应的指令实现对我司机器人的控制。
Expand Down
35 changes: 27 additions & 8 deletions SCTcpToolWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("连接已断开!!!")));

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -470,22 +470,18 @@ 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();
}
if (_reqFinished) { // 在发送完指令,并接受到响应之后再断开连接
_reqFinished = false; // 提前重置标志,防止界面上输出多有的信息
_pSCStatusTcp->releaseTcpSocket();
ui->comboBox_port->setEnabled(true);
ui->comboBox_sendCommand->setEnabled(true);
}
}

Expand Down Expand Up @@ -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);
}
}
10 changes: 9 additions & 1 deletion SCTcpToolWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand All @@ -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:
Expand Down

0 comments on commit 999aff5

Please sign in to comment.