1.思维导图
2.
输入闹钟时间格式是小时:分钟
widget.cpp
#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);id = startTimer(1000);flag=1;speecher = new QTextToSpeech(this);player = new QMediaPlayer(this);player->setMedia(QUrl::fromEncoded("qrc:/picture/凑诗_一千斛担子-一簇奇思妙想的火-原神七七x胡桃同人曲.mp3"));player->setVolume(50);this->setWindowFlag(Qt::FramelessWindowHint);this->setAttribute(Qt::WA_TranslucentBackground);
}Widget::~Widget()
{delete ui;
}void Widget::on_btn1_clicked()
{if(ui->btn1->text()=="启动"){flag=0;ui->btn1->setText("关闭");}else{flag=1;ui->btn1->setText("启动");}
}
void Widget::timerEvent(QTimerEvent *event)
{if(event->timerId()==id){QTime sys_time = QTime::currentTime();QString t = sys_time.toString("hh:mm:ss");QString t2 = sys_time.toString("hh:mm");ui->lab1->setText(t);ui->lab1->setAlignment(Qt::AlignCenter);if(ui->led1->text() == t2 && flag==0){flag=1;for(int i=0;i<3;i++){speecher->say(ui->lab3->text());}player->play();}}
}void Widget::on_pushButton_clicked()
{this->close();
}