1.官方示例
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPixmap pixmap(":/splash.png");
QSplashScreen splash(pixmap);
splash.show();
app.processEvents();
...
QMainWindow window;
window.show();
splash.finish(&window);
return app.exec();
}
2.使用定时器
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
QPixmap pixmap(":/icon/qt.ico");
QSplashScreen splash(pixmap);
splash.show();
QTimer::singleShot(1500, &splash, SLOT(hide()));
QTimer::singleShot(2000, &w, SLOT(show()));
//w.show();
return a.exec();
}
实质上是一样的,官方的会更好点