读书人

Qt程序起动画面QSplashScreen

发布时间: 2012-09-07 10:38:15 作者: rapoo

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();}

读书人网 >QT开发

热点推荐