程序
main.cpp
#include "mainwindow.h"
#include <QApplication>
#include <QPixmap>
#include <QSplashScreen>
#include <QLabel>
#include <windows.h>
#include <QMovie>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//静态程序启动画面
/*QPixmap pixmap("Qt.png");
QSplashScreen splash(pixmap);
splash.show();
a.processEvents();//使程序在显示启动动画时仍能响应鼠标等其他事件*/
//动态程序启动画面
QPixmap pix("splash2.gif");
QSplashScreen splash(pix);
//动态添加的步骤
QLabel splashlabel(&splash);
QMovie splashgif("splash2.gif");
splashlabel.setMovie(&splashgif);
splashgif.start();
splash.show();
splash.setCursor(Qt::BlankCursor);
//使程序在显示启动动画时仍能响应鼠标等其他事件,使程序休眠几秒以便于动态态启动
for(int i=0;i<15000;i+=splashgif.speed()){
QCoreApplication::processEvents();
Sleep(splashgif.speed()/3);
}
MainWindow w;
w.show();
splash.finish(&w);//在主窗体打开后结束启动动画
return a.exec();
}
效果展示
静态
动态