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);
}
相关推荐
lzhdim13 分钟前
C# 中读取CPU、硬盘和内存温度
开发语言·c#
Irene199114 分钟前
Oracle PL/SQL Developer 版本差异(11g、14)实战总结
java·开发语言
qq_4480111622 分钟前
C语言中的getchar()
c语言·开发语言
肖志-AI全栈27 分钟前
JavaScript 快速排序:从 pivot、双指针到分治思想
开发语言·javascript·排序算法
野生风长44 分钟前
c++类和对象(this指针,重载operator,习题总结)
java·开发语言·c++
雪的季节1 小时前
Python「假多态」与 C++「真多态」的核心区别
开发语言·c++
zmzb01031 小时前
C++课后习题训练记录Day166
开发语言·c++
皓月斯语1 小时前
程序设计语言的特点
开发语言·数据结构·c++
超人不会飞_Jay2 小时前
Go课程2
开发语言·后端·golang
Billy121382 小时前
结构化绑定与 if constexpr
开发语言·c++进阶学习