How to Add a Splash Screen for Your Qt Application

Posted on Posted in Qt Tutorials, Tutorials

Qt provides QSplashScreen class in case you want to have a splash screen for your application without any efforts. You can use the approach below to add an splash screen image of your choice using QSplashScreen and QPixmap classes that stays for 1 second and then disappears.

Change your application’s main.cpp file as shown below and it’s done!

Please note that you can also use a image added to Resources instead of a file saved to disk as is the case in example below:

#include “mainwindow.h”
#include <QApplication>
#include <QSplashScreen>
#include <QThread>

int main(int argc, char *argv[])
QApplication app(argc, argv);
QPixmap pixmap(“c:/images/splash.png”);
QSplashScreen splash(pixmap);;
app.thread()->sleep(1); // wait for just 1 second and then show main window
MainWindow window;;
return app.exec();

Leave a Reply

Your email address will not be published. Required fields are marked *