#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
, speecher(new QTextToSpeech(this))
{
ui->setupUi(this);
//启动一个定时器
id = startTimer(1000);
}
Widget::~Widget()
{
delete ui;
}
void Widget::timerEvent(QTimerEvent *e)
{
if(e->timerId() == id)
{
QTime s = QTime::currentTime();
ui->label->setText(s.toString("hh::mm::ss"));
}
else if(e->timerId() == id2)
{
if(ui->lineEdit->text() == ui->label->text())
{
for(int i=0; i<5;i++)
{
speecher->say(ui->label_3->text());
}
}
}
}
void Widget::on_pushButton_clicked()
{
id2 = startTimer(1000);
}
QT
最新推荐文章于 2024-09-30 11:08:34 发布