#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
id_1=startTimer(1000);
speecher=new QTextToSpeech;
}
Widget::~Widget()
{
delete ui;
}
void Widget::timerEvent(QTimerEvent *event)
{
if(event->timerId()==id_1)
{
QTime sys_t=QTime::currentTime();
ui->show_time->setText(sys_t.toString());
}
if(event->timerId()==id_2)
{
speecher->say(ui->textEdit->toPlainText());
killTimer(id_2);
}
}
void Widget::on_pushButton_clicked()
{
set_time=QTime::fromString(ui->time_input->text(),"h.m");
ui->show2->setText(set_time.toString());
if(set_time>QTime::currentTime())
{
int gap=(set_time.hour()-QTime::currentTime().hour())*3600+
(set_time.minute()-QTime::currentTime().minute())*60+
(set_time.second()-QTime::currentTime().second());
id_2=startTimer(gap*1000);
qDebug()<<gap;
}
else
{
int gap=(set_time.hour()-QTime::currentTime().hour()+24)*3600+
(set_time.minute()-QTime::currentTime().minute())*60+
(set_time.second()-QTime::currentTime().second());
id_2=startTimer(gap*1000);
qDebug()<<gap;
}
}
1、11作业
最新推荐文章于 2024-11-16 10:02:08 发布