-
Notifications
You must be signed in to change notification settings - Fork 4
/
widget.cpp
54 lines (46 loc) · 967 Bytes
/
widget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "widget.h"
#include "ui_widget.h"
widget::widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::widget)
{
setGeometry(0, 0, 800, 25);
ui->setupUi(this);
th = NULL;
}
widget::~widget()
{
delete ui;
}
void widget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void widget::on_pushButton_in_clicked()
{
// QString text = ui->comboBox->currentText();
th = new Thread("/dev/ttyACM0", this);
th->start();
connect(th, SIGNAL(serialFinished(QByteArray)), this, SLOT(ReadData(QByteArray)));
}
void widget::ReadData(QByteArray temp)
{
ui->lineEdit_in->setText(temp);
//ui->textBrowser->insertPlainText(tr("\n\n"));
}
void widget::closeEvent(QCloseEvent *event)
{
if(th != NULL)
{
th->stopThread();
th->wait();
}
event->accept();
}