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
| #include "countdown.h"
#include "ui_countdown.h"
countdown::countdown(QWidget *parent) :
QWidget(parent),
ui(new Ui::countdown)
{
ui->setupUi(this);
chrono();
}
countdown::~countdown()
{
delete ui;
}
/*************************************/
/************* COUNTDOWN *************/
/*************************************/
void countdown::chrono()
{
long cpt=0;
while(true){
QTimer *t = new QTimer();
t->start(10);
connect(t, SIGNAL(timeout()), this, SLOT(maj()));
cpt++;
}
}
void countdown::maj()
{
long diff;
datetime dateNow;
diff = *dateC-dateNow;
if(diffsec<0)
diffsec=99;
QString tmp;
if(diffsec<10)
tmp= "0" + QString::number(diffsec);
else
tmp = QString::number(diffsec);
ui->ctdwn->setText(QString::number(diff)+"."+tmp);
diffsec=diffsec-1;
} |