Qt5 QSplashScreen实现程序启动画面和动画

1.效果 

 2.代码

#include "mainwindow.h"
#include <QApplication>
#include <QLabel>
#include <QMovie>
#include <QSplashScreen>
#include <QThread>


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QPixmap pixmapImage(":/face.jpg");      // 图片
    QPixmap pixmapGif(":/loading.gif");     // 动画

    QSplashScreen splashImage(pixmapImage);
    QSplashScreen splashGif(pixmapGif);

    QMovie* pMovie = new QMovie(":/loading.gif");
    QLabel* pLabel = new QLabel(&splashGif);
    pLabel->setMovie(pMovie);
    pMovie->start();

    splashImage.show();
    splashGif.show();

    MainWindow w;
    w.show();

    splashImage.finish(&w);
    splashGif.finish(&w);

    return a.exec();
}



 

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页