使用QSplashScreen类可实现启动画面的添加

#include "widget.h"
#include <QApplication>
#include <QSplashScreen>
#include <QElapsedTimer>

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

QSplashScreen *splash = new QSplashScreen;
splash->setPixmap(QPixmap(":/images/images/a.jpg"));//这里要自行添加资源文件
splash->show();
QElapsedTimer t;//这里让图片显示三秒
t.start();
while (t.elapsed() < 3000) QCoreApplication::processEvents();
Widget w;
w.show();
splash->finish(&w);//随着窗口的出现图片应该消失
delete splash;

return a.exec();
}