.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QTime>
#include <QTimerEvent>
#include <QTextToSpeech>
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
//时间事件函数
void timerEvent(QTimerEvent *e);
signals:
private slots:
void on_startbtn_clicked();
void on_endbtn_clicked();
private:
Ui::Widget *ui;
QTextToSpeech *speecher;
int tid1;
int tid2;
};
#endif // WIDGET_H
.cpp
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
speecher = new QTextToSpeech(this);
//1.固定系统时间展示
QTime sys_tinme = QTime::currentTime();
QString t = sys_tinme.toString("h