当前位置: 代码迷 >> QT开发 >> Qt程序起动画面QSplashScreen
  详细解决方案

Qt程序起动画面QSplashScreen

热度:99   发布时间:2016-04-25 04:36:12.0
Qt程序启动画面QSplashScreen

QSplashScreen会在应用程序的主窗口出现之前显示一个图片!

?

?

#include "qmain.h"#include <QtGui/QApplication>#include <QSplashScreen>int main(int argc, char *argv[]){    QApplication app(argc, argv);    QPixmap pixmap(":/MyPicture/Resources/president.jpg");    QSplashScreen *splash = new QSplashScreen(pixmap);    splash->show();    //显示信息    splash->showMessage("Wait...");    Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;    splash->showMessage(QObject::tr("Setting up the main window..."),topRight, Qt::white);//显示信息    qApp->processEvents();//This is used to accept a click on the screen so that user can cancel the screen    QMain window;    window.setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px}");    window.show();    //图片一直显示到mainWin加载完成	splash.finish(&window);    delete splash;    return app.exec();}
  相关解决方案