-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.cpp
More file actions
63 lines (44 loc) · 1.17 KB
/
Copy pathtimer.cpp
File metadata and controls
63 lines (44 loc) · 1.17 KB
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
55
#include "timer.h"
#include "mainwindow.h"
Timer::Timer(QObject *parent) : QObject(parent)
{
createWorkTimer();
}
void Timer::createWorkTimer()
{
WorkTimer=new QTimer(this);
setWorkingInterval(QTime(0,0));
WorkTimer->setTimerType(Qt::PreciseTimer);
//SLOT
//connect(WorkTimer,SIGNAL(timeout()),this,SLOT());
}
QTime Timer::elapsed(QTime first,QTime second)
{
int sec1=first.hour()*3600+first.minute()*60+first.second();
int sec2=second.hour()*3600+second.minute()*60+second.second();
int r=sec1-sec2;
return QTime(r/3600,(r%3600)/60,(r%3600)%60);
}
void Timer::startWorking()
{
WorkTimer->start();
}
void Timer::setWorkingInterval(QTime arg)
{
this->workingTime=arg;
int milis=(workingTime.hour()*3600+workingTime.minute()*60+workingTime.second())*1000;
WorkTimer->setInterval(milis);
}
void Timer::stopWorking()
{
WorkTimer->stop();
}
QTime Timer::remaining()
{
int time = WorkTimer->remainingTime()/1000;
return QTime(time/(60*60), time/60, time%60);
}
void Timer::change_time() {
QString text = remaining().toString("hh:mm:ss");
clock->display(text);
}