10.20作业

#include "widget.h"

#include "ui_widget.h"
:
QWidget(parent)

复制代码
, ui(new Ui::Widget)   

{   

ui-\>setupUi(this);   

t = new QTimer(this);   

connect(t, \&QTimer::timeout, this, \&Widget::timeout_Slot);   

ui-\>text-\>setPlaceholderText("请输入时间: **:** 😗\*");   

speecher = new QTextToSpeech(this);   

}

Widget::~Widget()

{

delete ui;

}

void Widget::on_btn1_clicked()

{

if("启动" == ui->btn1->text())

{

//启动一个定时器

t->start(1000);

}

}

void Widget::on_btn2_clicked()

{

if("停止" == ui->btn2->text())

{

killTimer(tId);

speecher->stop();

}

}

void Widget::timeout_Slot()

{

QTime sys_tem = QTime::currentTime();

复制代码
QString s = sys_tem.toString("hh:mm:ss");

ui->lab1->setText(s);

ui->lab1->setAlignment(Qt::AlignCenter);

QString clock = ui->text->text();
if (clock == ui->lab1->text())
{
    int i = 0;
    while(i < 20)
    {
        i++;
        speecher->say(ui->lab2->text());
    }
}

}

相关推荐
m0_5870989918 小时前
Qt,二进制文件读写建议
开发语言·qt
秋田君18 小时前
QT_QT信号与槽机制
开发语言·数据库·qt
辞旧 lekkk18 小时前
【Qt】 系统相关:事件与定时器
开发语言·qt·学习·萌新
HAPPY酷18 小时前
【ROS2】VMware + Docker 运行 Gazebo 崩溃与“假死”排查实录
qt·docker·容器
初阳7851 天前
【Qt】界面优化(1)——QSS
开发语言·qt
Irissgwe1 天前
第六章 界面优化
qt
必须得开心呀1 天前
QT解决中文乱码问题
开发语言·qt
熊猫_豆豆2 天前
QT6 Android C++ 自制美观闹钟
android·c++·qt·闹钟
hssfscv2 天前
QT的学习笔记4——QMainWindow、资源文件以及主要控件的介绍
笔记·qt·学习
luoyayun3612 天前
Qt + FFmpeg 音频工具:重采样实现
qt·ffmpeg·重采样