QSplashScreen设置启动画面

QApplication app(argc, argv);
QSplashScreen *splash = new QSplashScreen;
splash->setPixmap(QPixmap(":/images/splash.png"));//设置图片
splash->show();//显示图片
Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
splash->showMessage(QObject::tr("Setting up the main window..."),topRight, Qt::white);//显示信息
MainWindow mainWin;
splash->showMessage(QObject::tr("Loading modules..."),
topRight, Qt::white); //显示信息
loadModules();
splash->showMessage(QObject::tr("Establishing connections..."),
topRight, Qt::white); //显示信息
establishConnections();
mainWin.show();
splash->finish(&mainWin);//图片一直显示到mainWin加载完成
delete splash;//释放空间,节省内存
return app.exec();

你可能感兴趣的:(开发实战)