Qt Jambi Home

com.trolltech.qt.gui
Class QSplashScreen

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by com.trolltech.qt.gui.QSplashScreen
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QSplashScreen
extends QWidget

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 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.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<java.lang.String> messageChanged
          This signal is emitted when the message on the splash screen changes.
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QSplashScreen()
          Equivalent to QSplashScreen(QPixmap(), 0).
QSplashScreen(QPixmap pixmap)
          Equivalent to QSplashScreen(pixmap, 0).
QSplashScreen(QPixmap pixmap, Qt.WindowFlags f)
          Construct a splash screen that will display the pixmap.
QSplashScreen(QWidget parent)
          Equivalent to QSplashScreen(parent, QPixmap(), 0).
QSplashScreen(QWidget parent, QPixmap pixmap)
          Equivalent to QSplashScreen(parent, pixmap, 0).
QSplashScreen(QWidget parent, QPixmap pixmap, Qt.WindowFlags f)
          This function allows you to specify a parent for your splashscreen.
 
Method Summary
 void clearMessage()
          Removes the message being displayed on the splash screen
protected  void drawContents(QPainter painter)
          Draw the contents of the splash screen using painter painter.
 boolean event(QEvent e)
          

This is the main event handler; it handles event arg__1.

 void finish(QWidget w)
          Makes the splash screen wait until the widget w is displayed before calling close on itself.
static QSplashScreen fromNativePointer(QNativePointer nativePointer)
          This function returns the QSplashScreen instance pointed to by nativePointer
protected  void mousePressEvent(QMouseEvent arg__1)
          

This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget.

 QPixmap pixmap()
          Returns the pixmap that is used in the splash screen.
 void setPixmap(QPixmap pixmap)
          Sets the pixmap that will be used as the splash screen's image to pixmap.
 void showMessage(java.lang.String message)
          Equivalent to showMessage(message, Qt::AlignLeft, Qt::black).
 void showMessage(java.lang.String message, int alignment)
          Equivalent to showMessage(message, alignment, Qt::black).
 void showMessage(java.lang.String message, int alignment, QColor color)
          Draws the message text onto the splash screen with color color and aligns the text according to the flags in alignment.
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mouseReleaseEvent, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

messageChanged

public final QSignalEmitter.Signal1<java.lang.String> messageChanged

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.

Compatible Slot Signatures:
void mySlot(java.lang.String message)
void mySlot()
See Also:
showMessage, clearMessage

Constructor Detail

QSplashScreen

public QSplashScreen(QPixmap pixmap)

Equivalent to QSplashScreen(pixmap, 0).


QSplashScreen

public QSplashScreen()

Equivalent to QSplashScreen(QPixmap(), 0).


QSplashScreen

public QSplashScreen(QPixmap pixmap,
                     Qt.WindowFlags f)

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

public QSplashScreen(QWidget parent,
                     QPixmap pixmap)

Equivalent to QSplashScreen(parent, pixmap, 0).


QSplashScreen

public QSplashScreen(QWidget parent)

Equivalent to QSplashScreen(parent, QPixmap(), 0).


QSplashScreen

public QSplashScreen(QWidget parent,
                     QPixmap pixmap,
                     Qt.WindowFlags f)

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.

Method Detail

clearMessage

public final void clearMessage()

Removes the message being displayed on the splash screen

See Also:
showMessage

finish

public final void finish(QWidget w)

Makes the splash screen wait until the widget w is displayed before calling close on itself.


pixmap

public final QPixmap pixmap()

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

setPixmap

public final void setPixmap(QPixmap pixmap)

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

See Also:
pixmap

showMessage

public final void showMessage(java.lang.String message,
                              int alignment)

Equivalent to showMessage(message, alignment, Qt::black).


showMessage

public final void showMessage(java.lang.String message)

Equivalent to showMessage(message, Qt::AlignLeft, Qt::black).


showMessage

public final void showMessage(java.lang.String message,
                              int alignment,
                              QColor color)

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, clearMessage

drawContents

protected void drawContents(QPainter painter)

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.


event

public boolean event(QEvent e)

This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

Overrides:
event in class QWidget
See Also:
closeEvent, focusInEvent, focusOutEvent, enterEvent, keyPressEvent, keyReleaseEvent, leaveEvent, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveEvent, paintEvent, resizeEvent, QObject::event, QObject::timerEvent

mousePressEvent

protected void mousePressEvent(QMouseEvent arg__1)

This event handler, for event arg__1, can be reimplemented in a subclass to receive mouse press events for the widget.

If you create new widgets in the mousePressEvent the mouseReleaseEvent may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.

The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.

Overrides:
mousePressEvent in class QWidget
See Also:
mouseReleaseEvent, mouseDoubleClickEvent, mouseMoveEvent, event, QMouseEvent, Example

fromNativePointer

public static QSplashScreen fromNativePointer(QNativePointer nativePointer)
This function returns the QSplashScreen instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home