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);
}
相关推荐
海绵宝宝转agent1 分钟前
LeetCode100 LRU缓存思路讲解
java·开发语言·缓存
AC赳赳老秦24 分钟前
OpenClaw 与 FineBI 联动方案:公开数据自动采集与实时业务分析看板实践
大数据·开发语言·python·php·finebi·deepseek·openclaw
通信瓦工29 分钟前
OCP 冷却环境与冷却剂分配单元(CDU)子项目
java·开发语言
坤坤子吖1 小时前
Python基础语法学习:函数
开发语言·笔记·python·学习
言乐61 小时前
Python体现逻辑回归和决策树的区别
开发语言·python·算法·决策树·逻辑回归
扶尔魔ocy1 小时前
【qt openGL入门笔记】坐标系统和摄像机
qt·opengl
LOVE️YOU1 小时前
Python 类与对象的核心逻辑:从 self、cls 到点号、括号与链式调用
开发语言·python
顶点多余1 小时前
C/C++常见面试题
开发语言·c++
(Charon)1 小时前
【C++面试】右值引用与移动语义:std::move到底做了什么
开发语言·c++
TheITSea1 小时前
JavaScript Web APIs
开发语言·前端·javascript