Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QSplashScreen Class Reference
[QtGui module]

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

#include <QSplashScreen>

Inherits QWidget.

Public Functions

  • 184 public functions inherited from QWidget
  • 28 public functions inherited from QObject
  • 10 public functions inherited from QPaintDevice

Public Slots

  • void clearMessage ()
  • void showMessage ( const QString & message, int alignment = Qt::AlignLeft, const QColor & color = Qt::black )
  • 17 public slots inherited from QWidget
  • 1 public slot inherited from QObject

Signals

Protected Functions

  • 39 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject

Additional Inherited Members

  • 52 properties inherited from QWidget
  • 1 property inherited from QObject
  • 4 static public members inherited from QWidget
  • 4 static public members inherited from QObject

Detailed Description

The 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 centered on the screen. It may be useful to add the Qt::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)
    {
        QApplication app(argc, argv);
        QPixmap pixmap("splash.png");
        QSplashScreen *splash = new QSplashScreen(pixmap);
        splash->show();
        QMainWindow *mainWin = new QMainWindow;
        ...
        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. 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().

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.

    QSplashScreen *splash = new QSplashScreen("splash.png");
    splash->show();
    ... // Loading some items
    splash->showMessage("Loaded modules");
    qApp->processEvents();
    ... // Establishing connections
    splash->showMessage("Established connections");
    qApp->processEvents();

Member Function Documentation

QSplashScreen::QSplashScreen ( const QPixmap & pixmap = QPixmap(), Qt::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 Qt::WindowStaysOnTopHint.

QSplashScreen::QSplashScreen ( QWidget * parent, const QPixmap & pixmap = QPixmap(), Qt::WFlags f = 0 )

This function allows you to specify a parent for your splashscreen. The typical use for this constructor is if you have a multiple screens and prefer to have the splash screen on a different screen than your primary one. In that case pass the proper desktop() as the parent.

QSplashScreen::~QSplashScreen ()   [virtual]

Destructor.

void QSplashScreen::clearMessage ()   [slot]

Removes the message being displayed on the splash screen

See also showMessage().

void QSplashScreen::drawContents ( QPainter * painter )   [virtual protected]

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

void QSplashScreen::finish ( QWidget * mainWin )

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

void QSplashScreen::messageChanged ( const QString & 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 showMessage() and clearMessage().

const QPixmap QSplashScreen::pixmap () const

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

See also setPixmap().

void QSplashScreen::repaint ()

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

void QSplashScreen::setPixmap ( const QPixmap & pixmap )

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

See also pixmap().

void QSplashScreen::showMessage ( const QString & message, int alignment = Qt::AlignLeft, const QColor & color = Qt::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 Qt::Alignment and clearMessage().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 9
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le Qt Developer Network au hasard

Logo

Introduction à Qt Quick pour les développeurs C++

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.0
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web