#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
settime();
id=startTimer(1000);
}
Widget::~Widget()
{
delete ui;
}
void Widget::timerEvent(QTimerEvent *event)
{
if(event->timerId()==id)
{
settime();
}
}
void Widget::settime()
{
QTime systime = QTime::currentTime();
QString s = systime.toString("hh:mm:ss");
ui->label->setText("当前时间 "+s);
if(s==settimeByUser)
{
ui->label_2->setText("懒虫,起床。好好学习,天天向上。\n响铃时间:"+s);
}
}
void Widget::on_pushButton_clicked()
{
settimeByUser = ui->lineEdit->text();
ui->label_2->setText("当前设定时间:"+settimeByUser);
}