QSplashScreen ClassThe QSplashScreen widget provides a splash screen that can be shown during application startup. More... #include <QSplashScreen> Inherits: QWidget. Public Types
Public Functions
Public Slots
Signals
Protected Functions
Reimplemented Protected Functions
Additional Inherited Members
Detailed DescriptionThe QSplashScreen widget provides a splash screen that can be shown during application startup. A splash screen is a widget that is usually displayed when an application is being started. Splash screens are often used for applications that have long start up times (e.g. database or networking applications that take time to establish connections) to provide the user with feedback that the application is loading. The splash screen appears in the center of the screen. It may be useful to add the Qt::WindowStaysOnTopHint to the splash widget's window flags if you want to keep it above all the other windows on the desktop. Some X11 window managers do not support the "stays on top" flag. A solution is to set up a timer that periodically calls raise() on the splash screen to simulate the "stays on top" effect. The most common usage is to show a splash screen before the main widget is displayed on the screen. This is illustrated in the following code snippet in which a splash screen is displayed and some initialization tasks are performed before the application's main window is shown: 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(); } The user can hide the splash screen by clicking on it with the mouse. Since the splash screen is typically displayed before the event loop has started running, it is necessary to periodically call QApplication::processEvents() to receive the mouse clicks. It is sometimes useful to update the splash screen with messages, for example, announcing connections established or modules loaded as the application starts up: QPixmap pixmap(":/splash.png"); QSplashScreen *splash = new QSplashScreen(pixmap); splash->show(); ... // Loading some items splash->showMessage("Loaded modules"); qApp->processEvents(); ... // Establishing connections splash->showMessage("Established connections"); qApp->processEvents(); QSplashScreen supports this with the showMessage() function. If you wish to do your own drawing you can get a pointer to the pixmap used in the splash screen with pixmap(). Alternatively, you can subclass QSplashScreen and reimplement drawContents(). Member Function Documentation
|