-
Notifications
You must be signed in to change notification settings - Fork 0
/
trafficlight.cpp
43 lines (36 loc) · 997 Bytes
/
trafficlight.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
#include "trafficlight.h"
#include "ui_trafficlight.h"
#include <QThread>
TrafficLight::TrafficLight(QWidget *parent) :
QWidget(parent),
ui(new Ui::TrafficLight)
{
ui->setupUi(this);
ui->startButton->setCheckable(true);
ui->stopButton->setCheckable(true);
connect(ui->startButton, SIGNAL(toggled(bool)), this, SLOT(start(bool)));
connect(ui->stopButton, SIGNAL(toggled(bool)), this, SLOT(stopSlot(bool)));
connect(this, SIGNAL(stopSign(bool)), ui->startButton, SLOT(setChecked(bool)));
}
TrafficLight::~TrafficLight()
{
delete ui;
}
void TrafficLight::start(bool run)
{
/*while(this->run)
{
QThread::sleep(1);
ui->greenRadio->setChecked(true);
QThread::sleep(1);
ui->yellowRadio->setChecked(true);
QThread::sleep(1);
ui->redRadio->setChecked(true);
QThread::sleep(1);
ui->yellowRadio->setChecked(true);
}*/
}
void TrafficLight::stopSlot(bool stop)
{
emit stopSign(!stop);
}