Skip to content

Commit

Permalink
整理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
才明洋 committed Jan 20, 2018
1 parent 45cd5d4 commit 5bb9d8b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion mainwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ void MainWidget::getRecv(QByteArray recv)
void MainWidget::OpenSerial()
{
QString portName = COMBox->currentText().split(' ')[0];
qDebug()<<portName;
emit requestOpen(portName);
emit setBaudRate(BaudrateBox->currentText());
emit setStopBits(StopbitsBox->currentText());
Expand Down
11 changes: 5 additions & 6 deletions mainwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <QByteArray>
#include "serialcontroller.h"

#include <QDebug>


class MainWidget : public QWidget
Expand All @@ -42,7 +41,7 @@ class MainWidget : public QWidget
void setParity(QString parity);
void sendData(QString content);
void sendStatus(QString status); //更新statusbar
void sendDateTime(QString datetime);
void sendDateTime(QString datetime); //更新stastatusbar中的时间

public slots:
void serialOpened(); //串口打开成功
Expand All @@ -52,11 +51,11 @@ public slots:
void OpenSerial();
void CloseSerial();
void ClearRecv();
void detNewLine(int state);
void detNewLine(int state); //处理发送新行
void ControlSendTimer(int state);
void changeSendTimer();
void detHex(int state);
void detRecvHex(int state);
void detHex(int state); //处理16进制发送
void detRecvHex(int state); //处理16进制接收

private:
QComboBox *COMBox, *BaudrateBox, *StopbitsBox, *DatabitsBox, *ParityBox;
Expand All @@ -77,7 +76,7 @@ public slots:
bool isSendHex = false;
bool isRecvHex = false;

QString HexStringToString(QString hexstr);
QString HexStringToString(QString hexstr); //解码16进制字符串

};

Expand Down
4 changes: 0 additions & 4 deletions serialcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void SerialController::closeSerial()
void SerialController::getBaudrate(QString baudrate)
{
serial->setBaudRate(baudrate.toInt());
qDebug()<<"The baudrate now is "<<baudrate.toInt();

}

Expand All @@ -46,13 +45,11 @@ void SerialController::getStopbits(QString stopbits)
serial->setStopBits(QSerialPort::OneAndHalfStop);
else if(stopbits == "2")
serial->setStopBits(QSerialPort::TwoStop);
qDebug()<<"The stopbits now is "<<stopbits;
}

void SerialController::getDatabits(QString databits)
{
serial->setDataBits(QSerialPort::DataBits(databits.toInt()));
qDebug()<<"The databits now is "<<databits;
}

void SerialController::getParity(QString parity)
Expand All @@ -65,7 +62,6 @@ void SerialController::getParity(QString parity)

else if(parity == tr("偶校验"))
serial->setParity(QSerialPort::EvenParity);
qDebug()<<"The parity now is "<<parity;
}

void SerialController::writeData(QString content)
Expand Down
1 change: 0 additions & 1 deletion serialcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <QObject>
#include <QSerialPort>
#include <QDebug>

class SerialController : public QObject
{
Expand Down

0 comments on commit 5bb9d8b

Please sign in to comment.