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);
}
相关推荐
我材不敲代码1 小时前
Python实现打包贪吃蛇游戏
开发语言·python·游戏
身如柳絮随风扬2 小时前
Java中的CAS机制详解
java·开发语言
韩立学长3 小时前
【开题答辩实录分享】以《基于Python的大学超市仓储信息管理系统的设计与实现》为例进行选题答辩实录分享
开发语言·python
froginwe114 小时前
Scala 循环
开发语言
m0_706653234 小时前
C++编译期数组操作
开发语言·c++·算法
故事和你914 小时前
sdut-Java面向对象-06 继承和多态、抽象类和接口(函数题:10-18题)
java·开发语言·算法·面向对象·基础语法·继承和多态·抽象类和接口
Bruk.Liu4 小时前
(LangChain实战2):LangChain消息(message)的使用
开发语言·langchain
qq_423233905 小时前
C++与Python混合编程实战
开发语言·c++·算法
m0_715575345 小时前
分布式任务调度系统
开发语言·c++·算法
csbysj20205 小时前
选择(Selectable)
开发语言