6.0.0-rc4Source

QSplashScreen Class

The QSplashScreen class shows a picture while the application starts. More…

Header#include <QSplashScreen>
CMaketarget_link_libraries(app PRIVATE Nt::Widgets)
ModuleNt Widgets C++ Classes
InheritsQWidget

List of all members, including inherited members

Public Functions

QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags())
~QSplashScreen()
voidsetPixmap(const QPixmap &pixmap)
QPixmappixmap() const
voidfinish(QWidget *mainWin)
QStringmessage() const

Reimplemented Public Functions

QSizesizeHint() const

Public Slots

voidshowMessage(const QString &message, int alignment = Qt::AlignLeft, const QColor &color = Qt::black)
voidclearMessage()

Signals

voidmessageChanged(const QString &message)

Protected Functions

virtual voiddrawContents(QPainter *painter)

Reimplemented Protected Functions

booleventFilter(QObject *watched, QEvent *event)
voidpaintEvent(QPaintEvent *event)
voidmousePressEvent(QMouseEvent *event)

Detailed Description

A splash screen is a frameless window in the middle of the screen with a pixmap and a message. Show it before the main window is made, and let it close when the main window shows:

QPixmap picture(400, 200);
picture.fill(Qt::darkCyan);
QSplashScreen splash(picture);
splash.show();
splash.showMessage("Loading plugins...", Qt::AlignBottom | Qt::AlignHCenter, Qt::white);
loadPlugins();
MainWindow window;
window.show();
splash.finish(&window);

The message is drawn over the pixmap; reimplement drawContents() to draw more. showMessage() repaints at once, so the message is seen even while the application is busy. A click closes the splash screen.

See also QPixmap.

Differences from Qt

There is no QSplashScreen(QScreen *) constructor, and pixmaps cannot be loaded from files in Nt, so the pixmap is painted by the application.

Member Function Documentation

[explicit] QSplashScreen::QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags())

Constructs a splash screen with the given pixmap and window flags f. It is a frameless window that stays on top.

[override] QSplashScreen::~QSplashScreen()

Destroys the splash screen.

[slot] void QSplashScreen::clearMessage()

Removes the message.

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

Draws the message with painter. Reimplement it to draw more over the pixmap.

[override, protected] bool QSplashScreen::eventFilter(QObject *watched, QEvent *event)

Reimplements QWidget::eventFilter().

The splash screen closes when the window given to finish() is shown.

void QSplashScreen::finish(QWidget *mainWin)

Closes the splash screen when mainWin is shown, or at once if it is shown already.

QString QSplashScreen::message() const

Returns the message that is shown, or an empty string.

[signal] void QSplashScreen::messageChanged(const QString &message)

This signal is emitted when the message changes to message.

[override, protected] void QSplashScreen::mousePressEvent(QMouseEvent *event)

Reimplements QWidget::mousePressEvent().

A click hides the splash screen.

[override, protected] void QSplashScreen::paintEvent(QPaintEvent *event)

Reimplements QWidget::paintEvent().

QPixmap QSplashScreen::pixmap() const

Returns the pixmap of the splash screen.

void QSplashScreen::setPixmap(const QPixmap &pixmap)

Sets the pixmap of the splash screen to pixmap; the window takes its size and moves to the middle of the screen.

See also pixmap().

[slot] void QSplashScreen::showMessage(const QString &message, int alignment = Qt::AlignLeft, const QColor &color = Qt::black)

Shows message over the pixmap, placed by alignment, in color, and repaints at once.

See also clearMessage() and messageChanged().

[override] QSize QSplashScreen::sizeHint() const

Reimplements QWidget::sizeHint().