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);
}
相关推荐
小小晓.12 分钟前
Qt 对话框、QLineEdit 与布局管理实战详解
开发语言·qt
炸薯条!44 分钟前
博客系统测试报告
开发语言·lua
Evand J1 小时前
【MATLAB例程12】永磁同步电机基于增广无迹卡尔曼滤波的未知负载转矩在线观测
开发语言·matlab
时间的拾荒人2 小时前
CMake 实战指南:从基础语法到静态库/动态库制作与链接
开发语言·c++·面试
xyouyuweizhu2 小时前
Java InetAddress 详解:从 IP 地址表示到主机名解析
java·开发语言·python
布莱克60511 小时前
C/C++ 中变量的声明与定义:区别、联系与常见误区
c语言·开发语言·c++·声明·定义
LabVIEW开发11 小时前
LabVIEW 局部变量为何引发竞争条件?四种同步机制
开发语言·labview
benchmark_cc12 小时前
A 股、港股、美股如何建立统一的标的主数据格式?
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
Zenova EdgeOS13 小时前
Go 工业边缘错误处理实战:用 errors 构建可追溯错误链
开发语言·数据库·golang
取名真是13 小时前
Python 算法知识点从基础到进阶
开发语言·python·算法