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);
}
相关推荐
一起吃元宵4 小时前
百度网盘下载不限速的办法_百度网盘不限速
开发语言·百度网盘·下载不限速·不限速·百度网盘不限速
人道领域4 小时前
【LeetCode刷题日记】47.全排列Ⅱ
java·开发语言·算法·leetcode
ch3nyuyu5 小时前
socket套接字
开发语言·php
源图客5 小时前
境外电商 - 龙虾智能体-综合选品推荐报告
开发语言·javascript·ecmascript
是苏浙5 小时前
Java实现链表1
java·开发语言
Jinkxs5 小时前
Rust 性能优化全流程:从 flamegraph 定位瓶颈到 unsafe 与 SIMD 加速,响应快 2 倍
开发语言·性能优化·rust
小短腿的代码世界5 小时前
Qt定时器高精度架构:从QTimer源码到纳秒级定时调度
数据库·qt·架构
尘中远6 小时前
Qt高性能绘图库QIm——实现二维三维科学绘图
开发语言·qt·信息可视化
雨辰AI6 小时前
从零搭建大模型本地运行环境|Python+CUDA 基础配置避坑大全
大数据·开发语言·人工智能·python·ai·ai编程·ai写作
DogDaoDao6 小时前
【第 05 篇】Python的字典与集合
开发语言·python·集合·字典