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);
}
相关推荐
‎ദ്ദിᵔ.˛.ᵔ₎11 分钟前
c++11:fuction包装器
开发语言·c++
kimnoic14 分钟前
Python 爬虫的原理
开发语言·python
Fluxproxy18 分钟前
Python爬虫异步提速终极方案|线程池ThreadPoolExecutor实战,告别单线程慢速爬取
开发语言·爬虫·python
淡海水31 分钟前
02-07-原理篇-GC暂停时间的本质
开发语言·unity·c#·gc·暂停时间
北i2 小时前
Dubbo 默认超时重试:把下游打雪崩的隐形放大器
开发语言·qt·dubbo
10mAh2 小时前
【Java】ArrayList 遍历删除为什么报错?三种写法与漏删复现
java·开发语言·windows
wewowilling2 小时前
AI大模型开发--01Python基础(无废话)
开发语言·python·函数
小羊没烦恼!2 小时前
OS X 上使用.NET开发应用程序
开发语言·前端·数据库·人工智能·c#·策略模式
棉猴2 小时前
玩游戏学Python5-函数
开发语言·python·函数·玩游戏·游戏编程
谢亮_vipxieliang3 小时前
JavaScript this 指向完全指南:调用位置决定一切
开发语言·javascript·ecmascript