#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
tId = startTimer(1000);
speecher = new QTextToSpeech(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_timerBtn_clicked()
{
if(ui->timerBtn->text() == "启动")
{
ui->timerLab->setText(ui->timerEdit->text());
timerId = startTimer(1000);
ui->timerBtn->setText("关闭");
}
else
{
killTimer(timerId);
ui->timerBtn->setText("启动");
}
}
void Widget::timerEvent(QTimerEvent *e)
{
if(e->timerId() == tId)
{
QTime curtime = QTime::currentTime();
QString t = curtime.toString("hh:mm:ss");
ui->curTimeLab->setText(t);
ui->curTimeLab->setAlignment(Qt::AlignCenter);
}
if(e->timerId() == timerId)
{
QTime curtime = QTime::currentTime();
QString t = curtime.toString("hh:mm:ss");
if(t == ui->timerEdit->text())
{
for(int i=0;i<5;i++)
{
speecher->say(ui->showLab->text());
}
killTimer(timerId);
ui->timerLab->clear();
ui->timerEdit->clear();
ui->timerBtn->setText("启动");
}
}
}
Day11.16
最新推荐文章于 2024-11-11 20:45:30 发布