Qt 程序启动画面

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kidults/article/details/88636946

#include <QSplashScreen>
#include <QPixmap>
#include <QElapsedTimer>
#include <QDateTime>


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

    QPixmap pixmap("loading.gif");  //gif图片不会动态变化
    QSplashScreen screen(pixmap);
    screen.show();
    //screen.showMessage("loading", Qt::AlignCenter, Qt::red);
    int delayTime = 5;
    QElapsedTimer timer;
    timer.start();
    while(timer.elapsed() < (delayTime * 1000))
    {
        app.processEvents();
    }

    Widget w;
    w.show();

    screen.finish(&w);

    return app.exec();
}

猜你喜欢

转载自blog.csdn.net/kidults/article/details/88636946