ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 概述 加载图片 ``` QApplication app(argc, argv); QSplashScreen *splash = new QSplashScreen; splash->setPixmap(QPixmap(":/img/1.png")); splash->show(); splash->showMessage( "Creating Widgets Page...",Qt::AlignHCenter | Qt::AlignVCenter,Qt::red);//居中,红色字体 app.processEvents(); //当处理的事件耗时较长时,保证所有事件处理完成后再继续往下执行 QThread::sleep(1); splash->showMessage( "Creating Database Page..." ); app.processEvents(); QThread::sleep(1); splash->showMessage( "Creating Games Page..." ); app.processEvents(); QThread::sleep(1); MainWindow mainwindow; QTimer::singleShot(2500, splash, SLOT(close())); QTimer::singleShot(2500, &mainwindow, SLOT(show())); return app.exec(); ``` 动态图 ``` QApplication a(argc, argv); //===动态程序启动画面=== QPixmap pix(":/resource/splash2.gif"); QSplashScreen splash(pix); QLabel splashlabel(&splash); QMovie splashgif(":/resource/splash2.gif"); splashlabel.setMovie(&splashgif); splashgif.start(); splash.show(); splash.setCursor(Qt::BlankCursor);//不显示鼠标外观 for(int i=0;i<15000;i+=splashgif.speed()){ QCoreApplication::processEvents(); Sleep(splashgif.speed()/5); } // QCoreApplication::processEvents(); toolbox w; w.show(); splash.finish(&w);//程序启动画面结束 return a.exec(); ```