#include "TimerDialog.h"
#include "ui_TimerDialog.h"
TimerDialog::TimerDialog(int ms,QWidget *parent) :
QDialog(parent),
ui(new Ui::TimerDialog)
{
ui->setupUi(this);
timer = new QTimer();
connect(timer,SIGNAL(timeout()),this,SLOT(onTimeout()));
timer->start(ms);
qDebug()<<"显示窗口:"<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz");
}
void TimerDialog::onTimeout()
{
qDebug()<<"时间到了,准备关闭:"<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz");
close();
timer->stop();
delete timer;
timer=nullptr;
}
TimerDialog::~TimerDialog()
{
delete ui;
}
评论0