t5 杂谈(二)Qt5:Qt中启动画面的设置[复制链接]上一主题下一主题

离线

艺术人生


加关注



— 本帖被 XChinux 执行加亮操作(2016-04-23) —

#include "mainwindow.h"
#include <QApplication>
#include <QSplashScreen>
#include <QTextEdit>
#include <QPixmap>
#include <QTest> //需要在工程文件当中加入 QT += testlib

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

QSplashScreen *splash = new QSplashScreen();
splash->setPixmap(QPixmap(":/p_w_picpaths/lubuntu_logo.png"));
splash->show();

a.processEvents();//这句话必须加上,不加的话,无法实现效果。

//QTest::qSleep(3000);

splash->showMessage(QObject::tr("Loading modules..."),
Qt::AlignCenter,
Qt::blue);
QTest::qSleep(6000);

MainWindow w;
w.show();
splash->finish(&w);
delete splash;

return a.exec();
}