blob: fad21f4e7be2ac04285f16feb5f4800b7273f0d0 (
plain)
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
|
#include "aoclocklabel.h"
AOClockLabel::AOClockLabel(QWidget *parent) : QLabel(parent) {}
void AOClockLabel::start()
{
this->resume();
}
void AOClockLabel::start(QTime p_time)
{
QTime time = QTime::currentTime();
if (p_time > time)
{
target_time = p_time;
starting_time = time;
timer.start(100, this);
}
}
void AOClockLabel::pause() {}
void AOClockLabel::resume() {}
void AOClockLabel::stop() {}
void AOClockLabel::timerEvent(QTimerEvent *event)
{
if (event->timerId() == timer.timerId()) {
QTime elapsed = QTime(0,0).addSecs(starting_time.secsTo(starting_time));
this->setText(elapsed.toString("hh:mm:ss.zzz"));
} else {
QWidget::timerEvent(event);
}
}
|