#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
tid1 = startTimer(1000);
speecher = new QTextToSpeech(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::timerEvent(QTimerEvent *e)
{
if(e->timerId() == tid1) {
QTime time = QTime::currentTime();
QString t = time.toString("hh::mm::ss");
ui->lab1->setText(t);
ui->lab1->setAlignment(Qt::AlignCenter);
}
if(e->timerId() == tid2) {
if(ui->lab1->text() == ui->line->text()) {
for(int i=5; i>0; i--) {
speecher->say(ui->lab4->text());
}
}
}
}
void Widget::on_pushButton_clicked()
{
tid2 = startTimer(1000);
}
qt实现闹钟
最新推荐文章于 2024-10-15 13:26:23 发布