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);
}
相关推荐
Fuyo_11192 分钟前
C++中的活字印刷术——模板·初阶
开发语言·c++·笔记
在角落发呆4 分钟前
跨越网络鸿沟:传统文件传输与现代内网穿透的奇妙交响
开发语言·php
Season4507 分钟前
C++之模板元编程(前置知识 constexpr)
开发语言·c++
AI玫瑰助手9 分钟前
Python运算符:比较运算符(等于不等等于大于小于)与返回值
android·开发语言·python
计算机安禾32 分钟前
【c++面向对象编程】第40篇:单例模式(Singleton)的多种C++实现
开发语言·c++·单例模式
_日拱一卒1 小时前
LeetCode:114二叉树展开为链表
java·开发语言·算法
天天进步20151 小时前
从零打造 Python 全栈项目:智能教学辅助系统
开发语言·人工智能·python
kkeeper~1 小时前
0基础C语言积跬步之内存函数
c语言·开发语言
吃好睡好便好1 小时前
在Matlab中绘制杆状图
开发语言·学习·算法·matlab·信息可视化
桀人1 小时前
C++——内存管理——new和delete的超详细解析
开发语言·c++