您的位置:首页 > 文旅 > 美景 > 微信怎么弄小程序店铺_深圳电信网络建站_推广网站都有哪些_营销软文500字

微信怎么弄小程序店铺_深圳电信网络建站_推广网站都有哪些_营销软文500字

2025/1/10 22:32:18 来源:https://blog.csdn.net/yk41000/article/details/144833013  浏览:    关键词:微信怎么弄小程序店铺_深圳电信网络建站_推广网站都有哪些_营销软文500字
微信怎么弄小程序店铺_深圳电信网络建站_推广网站都有哪些_营销软文500字

增加testtospeech模块

QT       += core gui texttospeech

头文件

#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <QTimerEvent>
#include <QTimer>
#include <QTime>
#include <QMouseEvent>
#include <QTextToSpeech>QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACEclass Widget : public QWidget
{Q_OBJECTpublic:Widget(QWidget *parent = nullptr);~Widget();void timerEvent(QTimerEvent *e) override;private slots:void on_pushButton_clicked();private:Ui::Widget *ui;int start_id = 0;int set_id = 0;bool flag = 0;QTextToSpeech *speecher;};
#endif // WIDGET_H

widget.cpp

#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget), speecher(new QTextToSpeech(this))
{ui->setupUi(this);start_id = startTimer(1000);}Widget::~Widget()
{delete ui;
}void Widget::on_pushButton_clicked()
{if(ui->pushButton->text() == "Setting"){flag = 1;ui->pushButton->setText("Cancel");
//        set_id = startTimer(1000);}else{flag = 0;ui->pushButton->setText("Setting");
//        killTimer(set_id);}
}void Widget::timerEvent(QTimerEvent *e)
{if(e->timerId() == start_id){//获取系统时间QTime sysTime = QTime::currentTime();ui->label_sysTime->setText(sysTime.toString());//方法1:if(ui->setTime->text() == sysTime.toString()&&flag){for(int i = 0;i<5;i++){speecher->say(ui->text->text());}ui->pushButton->setText("Setting");flag = 0;}}if(e->timerId() == set_id){//方法2://获取系统时间
//        QTime sysTime = QTime::currentTime();
//        if(ui->setTime->text() == sysTime.toString())
//        {
//            for(int i = 0;i<5;i++)
//            {
//                speecher->say(ui->text->text());
//            }
//
//            ui->pushButton->setText("Setting");
//            flag = 1;
//        }}
}

ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>Widget</class><widget class="QWidget" name="Widget"><property name="geometry"><rect><x>0</x><y>0</y><width>800</width><height>600</height></rect></property><property name="windowTitle"><string>Widget</string></property><property name="styleSheet"><string notr="true"/></property><widget class="QLabel" name="label_sysTime"><property name="geometry"><rect><x>80</x><y>50</y><width>281</width><height>151</height></rect></property><property name="font"><font><pointsize>34</pointsize></font></property><property name="text"><string/></property><property name="alignment"><set>Qt::AlignCenter</set></property></widget><widget class="QPushButton" name="pushButton"><property name="geometry"><rect><x>510</x><y>130</y><width>141</width><height>71</height></rect></property><property name="font"><font><pointsize>18</pointsize></font></property><property name="text"><string>Setting</string></property></widget><widget class="QLabel" name="text"><property name="geometry"><rect><x>80</x><y>270</y><width>611</width><height>251</height></rect></property><property name="font"><font><pointsize>46</pointsize></font></property><property name="text"><string>it's time to go</string></property></widget><widget class="QLineEdit" name="setTime"><property name="geometry"><rect><x>440</x><y>50</y><width>271</width><height>61</height></rect></property><property name="font"><font><pointsize>16</pointsize></font></property><property name="alignment"><set>Qt::AlignCenter</set></property><property name="placeholderText"><string>hh:mm:ss</string></property></widget></widget><resources/><connections/>
</ui>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com