Splash Screens

Many applications present a splash screen at startup. Some developers use a splash screen to disguise a slow startup, while others do it to satisfy their marketing departments. Adding a splash screen to Qt applications is very easy using the QSplashScreen class.

The QSplashScreen class shows an image before the application proper has started. It can also draw a message on the image, to inform the user about the progress of the application's initialization process. Typically, the splash screen code is located in main(), before the call to QApplication::exec().

Below is an example main() function that uses QSplashScreen to present a splash screen in an application that loads modules and establishes network connections at startup.

int main(int argc, char *argv[])
 QApplication app(argc, argv);
 QSplashScreen *splash =
 new QSplashScreen(QPixmap::fromMimeSource("splash.png"));

 splash->message(QObject::tr("Setting up the main window..."),
 Qt::AlignRight | Qt::AlignTop, Qt::white);
 MainWindow mainWin;

 splash->message(QObject::tr("Loading modules..."),
 Qt::AlignRight | Qt::AlignTop, Qt::white);

 splash->message(QObject::tr("Establishing connections..."),
 Qt::AlignRight | Qt::AlignTop, Qt::white);

 delete splash;

 return app.exec();

Figure 3.18. A QSplashScreen widget


We have now completed the Spreadsheet application's user interface. In the next chapter, we will complete the application by implementing the core spreadsheet functionality.

Part I: Basic Qt

Getting Started

Creating Dialogs

Creating Main Windows

Implementing Application Functionality

Creating Custom Widgets

Part II: Intermediate Qt

Layout Management

Event Processing

2D and 3D Graphics

Drag and Drop


Container Classes





Providing Online Help


Platform-Specific Features

show all menu

C++ GUI Programming with Qt 3
C++ GUI Programming with Qt 3
ISBN: 0131240722
EAN: 2147483647
Year: 2006
Pages: 140
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net