#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
id = startTimer(1000);
speecher = new QTextToSpeech(this);
ui->lab2->setAlignment(Qt::AlignCenter);
}
Widget::~Widget()
{
delete ui;
}
void Widget::timerEvent(QTimerEvent *e)
{
QTime sys_time = QTime::currentTime();
QString t = sys_time.toString("hh::mm::ss");
ui->lab1->setText(t);
ui->lab1->setAlignment(Qt::AlignCenter);
int count;
if(ui->btn1->text()=="取消设置")
{
if(ui->lab1->text()==ui->lineEdit->text())
{
count=0;
while(1)
{
if(count<5)
{
speecher->say(ui->lab2->text());
count++;
}
else
break;
}
}
}
}
void Widget::on_btn1_clicked()
{
if(ui->btn1->text()=="设置")
{
ui->btn1->setText("取消设置");
}
else
{
ui->btn1->setText("设置");
}
}