forked from yangsheng6810/pvz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsunlight.cpp
More file actions
30 lines (27 loc) · 753 Bytes
/
sunlight.cpp
File metadata and controls
30 lines (27 loc) · 753 Bytes
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
#include "sunlight.h"
SunLight::SunLight(QWidget *parent) :
QWidget(parent),sunLight(1000)
{
lcd = new QLCDNumber(4);// for debug
connect(this,SIGNAL(updateSun(int)),lcd,SLOT(display(int)));
QPushButton* button = new QPushButton(tr("add sunlight"));
connect(button, SIGNAL(clicked()),this,SLOT(addSunLight()));
QHBoxLayout* layout = new QHBoxLayout;
layout->addWidget(lcd);
layout->addWidget(button);
this->setLayout(layout);
}
void SunLight::addSunLight(int num)
{
sunLight += num;
if (sunLight > 9990)
sunLight = 9990;
emit updateSun(sunLight);
}
void SunLight::addSunLight()// for debug
{
sunLight += 50;
if (sunLight > 9990)
sunLight = 9990;
emit updateSun(sunLight);
}