#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
speecher = new QTextToSpeech(this);
}
Widget::~Widget()
{
delete ui;
}
//显示系统时间
void Widget::timerEvent(QTimerEvent *e)
{
QTime sys_time = QTime::currentTime(); //获取系统时间
QString t = sys_time.toString("hh::mm::ss");
ui->lab->setText(t); //显示
if(ui->lab->text() == ui->lab2->text())
{
ui->lab3->setText("好好学习");
speecher->say(ui->lab3->text());
}
}
void Widget::on_btn1_clicked()
{
if(ui->btn1->text() == "启动")
{
id = startTimer(1000);
ui->btn1->setText("关闭");
}else {
killTimer(id);
ui->btn1->setText("启动");
}
}