QT5练习

1

2

复制代码
#include "mywidget.h"
#include "ui_mywidget.h"

myWidget::myWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::myWidget)
{
    ui->setupUi(this);

    ui->label1->setAlignment(Qt::AlignCenter);
    speecher=new QTextToSpeech(this);
    startTimer(1000);
    emit settime();
}


myWidget::~myWidget()
{
    delete ui;
}


void myWidget::timerEvent(QTimerEvent *e)
{

    emit settime();
    if(num==ui->label1->text())
    {
        for(int i=0;i<5;i++)
        {
            speecher->say("你是小黑子");
        }
        QMovie *mv=new QMovie("C:\\Users\\18065\\Desktop\\pictrue\\kun.gif");
        mv->setParent(this);
        ui->label3->setMovie(mv);
        mv->start();
        ui->label3->setScaledContents(true);
    }
}

void myWidget::settime()
{
    QTime time=QTime::currentTime();
    QString t=time.toString("hh:mm:ss");
    ui->label1->setText(t);
}
相关推荐
ComPDFKit4 小时前
RAG 回答只显示 PDF 文件名?用 Python 保留引用页码
开发语言·python·pdf·rag
FRing034 小时前
vue3干货总结2(vue3生命周期、父子通信、模版引用、provide和inject)
开发语言·前端·vue.js·vue3
琳少_6 小时前
java程序开发笔记
java·开发语言·数据库·笔记
七夜zippoe6 小时前
Agent 告警设计:分级告警、智能降噪与值班排班
开发语言·ai·agent·告警·智能降噪·值班排班
严肃小白兔8 小时前
PHP 8.6 正式发布:部分函数应用、原生 I/O 轮询与新特性实战解析
开发语言·php
郝学胜-神的一滴8 小时前
Effective Python 条款36:优雅拼装迭代器与生成器
开发语言·数据结构·人工智能·python·numpy·scikit-learn
wuyk55510 小时前
Python办公自动化-第04讲-批量新建Excel
开发语言·python·excel
宏笋10 小时前
Qt开发了一款绘图和制作信笺的软件
qt
code2cat11 小时前
【随笔】Java客户端选了HTTP/3,怎样知道请求实际走了哪个版本
java·开发语言·http
honker_X14 小时前
Python字符串全攻略:从入门到精通
开发语言·python