#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
,speecher(new QTextToSpeech(this))
{
ui->setupUi(this);
this->setWindowFlag(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);
}
Widget::~Widget()
{
delete ui;
}
void Widget::timerEvent(QTimerEvent *e)
{
if(e->timerId() == id1)
{
QTime sys=QTime::currentTime();
QString st= sys.toString("hh:mm:ss");
ui->label2->setText(st);
ui->label2->setAlignment(Qt::AlignCenter);
if(st == ui->lineEdit->text())
{
for(int i=0;i<5;i++)
{
speecher->say(ui->label3->text());
}
}
}
}
void Widget::on_btn1_clicked()
{
if(ui->btn1->text() == "启动")
{
id1 = startTimer(1000);
ui->btn1->setText("关闭");
}
else
{
killTimer(id1);
ui->btn1->setText("启动");
}
}
911作业
于 2024-09-12 08:49:04 首次发布