I don't understand why you are using QMainWindow for the splash screen when Qt has a QSplashScreen class for this purpose. I also don't understand why you are using calls to sleep() instead of using a single-shot QTimer to control the length of time the splash screen is displayed.
The usual scenario is:
- Create the QSplashScreen instance
- Create the QMainWindow instance. Do not call show() on it.
- Tell the splash screen that it should close when the main window is shown (QSplashScreen::finish())
- show() the splash screen
- Create a single-shot QTimer and connect its timeout() signal to the main window's show() slot, then start the timer.
- app.exec_()
If loading the background data is time consuming, then instead of using a QTimer, have the data loading method call show() on the main window when it finishes. That way, the splash screen will be displayed for as long as it takes to complete loading your data.
Bookmarks