#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
,speecher(new QTextToSpeech(this))
{
ui->setupUi(this);
connect(ui->pushButton,&QPushButton::clicked,this,&Widget::my_slot);
}
Widget::~Widget()
{
delete ui;
}
void Widget::timerEvent(QTimerEvent *event)
{
if(event->timerId() == id)
{
QTime sys_time =QTime::currentTime();
QString t =sys_time.toString("hh:mm:ss");
ui->label->setText(t);
ui->label->setAlignment(Qt::AlignCenter);
}
else if(event->timerId() == id2)
{
if(ui->lineEdit->text() == ui->label->text())
{
qDebug() << "有用呀" ;
ui->label_3->setText("再睡一会会儿");
for(int i = 0;i < 5; i++)
{
speecher->say(ui->label_3->text());
}
}
}
}
void Widget::on_pushButton_clicked()
{
if(ui->lineEdit->text()=="")
{
QMessageBox::information(this,"提示","未输入时间");
}
}
void Widget::my_slot()
{
id2 = startTimer(1000);
}