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);
}
相关推荐
OPEN-F3 分钟前
Python进阶教程:项目工程化与虚拟环境
开发语言·python
吴声子夜歌5 分钟前
Java面试——基础
java·开发语言·面试
智嵌研习社1 小时前
Ollama 本地大模型完全配置指南:Modelfile 参数与系统环境变量深度解析
java·开发语言
XZ-0700011 小时前
1-1-可视化-练习
开发语言·python
橙橙笔记1 小时前
Python学习第三部分
开发语言·python·学习
huainingning2 小时前
个人版WorkBuddy编写设备巡检并导出设备配置python脚本
开发语言·python
Java后端的Ai之路2 小时前
02、Python普通工厂模式
开发语言·人工智能·python·设计模式·普通工厂模式
韶博雅2 小时前
开启补充日志
java·开发语言·sql
被怪兽吃掉了3 小时前
5.2.1一维组数定义方式
开发语言·c++·算法
TheBestRucy3 小时前
Python 九阳神功之肆:网络编程 · Socket 从入门到实战
开发语言·网络·python