作业
cpp
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
, speech(new QTextToSpeech)
{
ui->setupUi(this);
id = startTimer(1000);
}
Widget::~Widget()
{
delete ui;
}
void Widget::timerEvent(QTimerEvent *e)
{
if(e->timerId() == id)
{
QTime time = QTime::currentTime();
ui->label->setText(time.toString("hh:mm:ss"));
if(time.toString("hh:mm:ss") == my_time)
{
for(int i=0;i<5;i++)
{
speech->say(ui->label_3->text());
}
}
}
}
void Widget::on_pushButton_clicked()
{
my_time = ui->lineEdit->text();
ui->label_5->setText(ui->lineEdit->text());
ui->lineEdit->clear();
}