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());
    }
}

}

相关推荐
sycmancia2 小时前
Qt——复习篇painter
开发语言·qt
Quz2 小时前
QML ProgressBar 基础用法:默认样式与平滑动画
qt
繁重的秋春2 小时前
Qt6.0下的CMake的部署配置
qt·cmake
qq_401700412 小时前
Qt 程序启动太乱?重新设计你的 Application 生命周期
开发语言·qt
Quz2 小时前
QML Tumbler 自定义滚轮:用 PathView 实现横向选择器
qt
Quz1 天前
QML Tumbler 样式定制:渐变、高亮与 3D 滚轮效果
qt
隐积2 天前
3.1.7.Qt容器大家族(3):QVariant——万能盒子
开发语言·qt
熬夜苦读学习2 天前
Qt-- 系统相关
开发语言·qt
Quz2 天前
QML Tumbler 基础用法:多滚轮选择与自定义外观
qt
Quz2 天前
QML SpinBox 动画效果:缩放反馈与数字滚动
qt