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

}

相关推荐
Felix_One3 天前
Qt 串口通信避坑指南:QSerialPort 的 5 个常见问题
qt
blasit6 天前
笔记:Qt C++建立子线程做一个socket TCP常连接通信
c++·qt·tcp/ip
范特西.i11 天前
QT聊天项目(8)
开发语言·qt
枫叶丹411 天前
【Qt开发】Qt界面优化(七)-> Qt样式表(QSS) 样式属性
c语言·开发语言·c++·qt
十五年专注C++开发11 天前
Qt deleteLater作用及源码分析
开发语言·c++·qt·qobject
kangzerun11 天前
SQLiteManager:一个优雅的Qt SQLite数据库操作类
数据库·qt·sqlite
金刚狼8811 天前
qt和qt creator的下载安装
开发语言·qt
追烽少年x11 天前
Qt中使用Zint库显示二维码
qt
谁刺我心11 天前
qt源码、qt在线安装器镜像下载
开发语言·qt
金刚狼8811 天前
在qt creator中创建helloworld程序并构建
开发语言·qt