Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# TQSplashScreen Class Reference

The TQSplashScreen widget provides a splash screen that can be shown during application startup. More...

`#include <ntqsplashscreen.h>`

Inherits TQWidget.

List of all member functions.

## Public Members

- TQSplashScreen ( const TQPixmap & pixmap = TQPixmap ( ), WFlags f = 0 )
- virtual ~TQSplashScreen ()
- void setPixmap ( const TQPixmap & pixmap )
- TQPixmap * pixmap () const
- void finish ( TQWidget * mainWin )
- void repaint ()

## Public Slots

- void message ( const TQString & message, int alignment = AlignLeft, const TQColor & color = black )
- void clear ()

## Signals

- void messageChanged ( const TQString & message )

## Protected Members

- virtual void drawContents ( TQPainter * painter )

## Detailed Description

The TQSplashScreen 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 centered on the screen. It may be useful to add the WStyle_StaysOnTop if you desire to keep above all the windows in the GUI.

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.

       int main( int argc, char **argv )
       {
           TQApplication app( argc, argv );
           TQPixmap pixmap( "splash.png" );
           TQSplashScreen *splash = new TQSplashScreen( pixmap );
           splash->show();
           TQMainWindow *mainWin = new TQMainWindow;
           ...
           app.setMainWidget( mainWin );
           mainWin->show();
           splash->finish( mainWin );
           delete splash;
           return app.exec();
       }

It is sometimes useful to update the splash screen with messages, for example, announcing connections established or modules loaded as the application starts up. TQSplashScreen supports this with the message() 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 TQSplashScreen and reimplement drawContents().

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 TQApplication::processEvents() to receive the mouse clicks.

       TQPixmap pixmap( "splash.png" );
       TQSplashScreen *splash = new TQSplashScreen( pixmap );
       splash->show();
       ... // Loading some items
       splash->message( "Loaded modules" );
       tqApp->processEvents();
       ... // Establishing connections
       splash->message( "Established connections" );
       tqApp->processEvents();

See also Miscellaneous Classes.

## Member Function Documentation

### TQSplashScreen::TQSplashScreen ( const TQPixmap & pixmap = TQPixmap ( ), WFlags f = 0 )

Construct a splash screen that will display the pixmap.

There should be no need to set the widget flags, f, except perhaps WDestructiveClose or WStyle_StaysOnTop.

### TQSplashScreen::~TQSplashScreen ()`[virtual]`

Destructor.

### void TQSplashScreen::clear ()`[slot]`

Removes the message being displayed on the splash screen

See also message().

### void TQSplashScreen::drawContents ( TQPainter * painter )`[virtual protected]`

Draw the contents of the splash screen using painter painter. The default implementation draws the message passed by message(). Reimplement this function if you want to do your own drawing on the splash screen.

### void TQSplashScreen::finish ( TQWidget * mainWin )

Makes the splash screen wait until the widget mainWin is displayed before calling close() on itself.

### void TQSplashScreen::message ( const TQString & message, int alignment = AlignLeft, const TQColor & color = black )`[slot]`

Draws the message text onto the splash screen with color color and aligns the text according to the flags in alignment.

See also TQt::AlignmentFlags and clear().

### void TQSplashScreen::messageChanged ( const TQString & message )`[signal]`

This signal is emitted when the message on the splash screen changes. message is the new message and is a null-string when the message has been removed.

See also message() and clear().

### TQPixmap * TQSplashScreen::pixmap () const

Returns the pixmap that is used in the splash screen. The image does not have any of the text drawn by message() calls.

### void TQSplashScreen::repaint ()

This overrides TQWidget::repaint(). It differs from the standard repaint function in that it also calls TQApplication::flush() to ensure the updates are displayed, even when there is no event loop present.

### void TQSplashScreen::setPixmap ( const TQPixmap & pixmap )

Sets the pixmap that will be used as the splash screen's image to pixmap.

This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.