<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QSplashScreen Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QSplashScreen Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QSplashScreen widget provides a splash screen that can be shown during application startup. <a href="#details">More...</a></p> <p>Inherits <a href="qwidget.html">QWidget</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qsplashscreen.html#QSplashScreen">__init__</a></b> (<i>self</i>, QPixmap <i>pixmap</i> = QPixmap(), Qt.WindowFlags <i>flags</i> = 0)</li><li><div class="fn" /><b><a href="qsplashscreen.html#QSplashScreen-2">__init__</a></b> (<i>self</i>, QWidget <i>parent</i>, QPixmap <i>pixmap</i> = QPixmap(), Qt.WindowFlags <i>flags</i> = 0)</li><li><div class="fn" /><b><a href="qsplashscreen.html#clearMessage">clearMessage</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsplashscreen.html#drawContents">drawContents</a></b> (<i>self</i>, QPainter <i>painter</i>)</li><li><div class="fn" />bool <b><a href="qsplashscreen.html#event">event</a></b> (<i>self</i>, QEvent <i>e</i>)</li><li><div class="fn" /><b><a href="qsplashscreen.html#finish">finish</a></b> (<i>self</i>, QWidget <i>w</i>)</li><li><div class="fn" /><b><a href="qsplashscreen.html#mousePressEvent">mousePressEvent</a></b> (<i>self</i>, QMouseEvent)</li><li><div class="fn" />QPixmap <b><a href="qsplashscreen.html#pixmap">pixmap</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsplashscreen.html#repaint">repaint</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsplashscreen.html#setPixmap">setPixmap</a></b> (<i>self</i>, QPixmap <i>pixmap</i>)</li><li><div class="fn" /><b><a href="qsplashscreen.html#showMessage">showMessage</a></b> (<i>self</i>, QString <i>message</i>, int <i>alignment</i> = Qt.AlignLeft, QColor <i>color</i> = Qt.black)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qsplashscreen.html#messageChanged">messageChanged</a></b> (const QString&)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QSplashScreen widget provides a splash screen that can be shown during application startup.</p> <p>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.</p> <p>The splash screen appears in the center of the screen. It may be useful to add the <a href="qt.html#WindowType-enum">Qt.WindowStaysOnTopHint</a> to the splash widget's window flags if you want to keep it above all the other windows on the desktop.</p> <p>Some X11 window managers do not support the "stays on top" flag. A solution is to set up a timer that periodically calls <a href="qwidget.html#raise">raise_</a>() on the splash screen to simulate the "stays on top" effect.</p> <p>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:</p> <pre class="cpp"> <span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>) { <span class="type"><a href="qapplication.html">QApplication</a></span> app(argc<span class="operator">,</span> argv); <span class="type"><a href="qpixmap.html">QPixmap</a></span> pixmap(<span class="string">":/splash.png"</span>); <span class="type">QSplashScreen</span> splash(pixmap); splash<span class="operator">.</span>show(); app<span class="operator">.</span>processEvents(); ... <span class="type"><a href="qmainwindow.html">QMainWindow</a></span> window; window<span class="operator">.</span>show(); splash<span class="operator">.</span>finish(<span class="operator">&</span>window); <span class="keyword">return</span> app<span class="operator">.</span>exec(); } </pre> <p>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 <a href="qcoreapplication.html#processEvents">QApplication.processEvents</a>() to receive the mouse clicks.</p> <p>It is sometimes useful to update the splash screen with messages, for example, announcing connections established or modules loaded as the application starts up:</p> <pre class="cpp"> <span class="type"><a href="qpixmap.html">QPixmap</a></span> <a href="qsplashscreen.html#pixmap">pixmap</a>(<span class="string">":/splash.png"</span>); <span class="type">QSplashScreen</span> <span class="operator">*</span>splash <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QSplashScreen</span>(pixmap); splash<span class="operator">-</span><span class="operator">></span><a href="qwidget.html#show">show</a>(); <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> <span class="comment">// Loading some items</span> splash<span class="operator">-</span><span class="operator">></span><a href="qsplashscreen.html#showMessage">showMessage</a>(<span class="string">"Loaded modules"</span>); qApp<span class="operator">-</span><span class="operator">></span>processEvents(); <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> <span class="comment">// Establishing connections</span> splash<span class="operator">-</span><span class="operator">></span><a href="qsplashscreen.html#showMessage">showMessage</a>(<span class="string">"Established connections"</span>); qApp<span class="operator">-</span><span class="operator">></span>processEvents(); </pre> <p>QSplashScreen supports this with the <a href="qsplashscreen.html#showMessage">showMessage</a>() function. If you wish to do your own drawing you can get a pointer to the pixmap used in the splash screen with <a href="qsplashscreen.html#pixmap">pixmap</a>(). Alternatively, you can subclass QSplashScreen and reimplement <a href="qsplashscreen.html#drawContents">drawContents</a>().</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSplashScreen" />QSplashScreen.__init__ (<i>self</i>, <a href="qpixmap.html">QPixmap</a> <i>pixmap</i> = QPixmap(), <a href="qt-windowflags.html">Qt.WindowFlags</a> <i>flags</i> = 0)</h3><p>Construct a splash screen that will display the <i>pixmap</i>.</p> <p>There should be no need to set the widget flags, <i>f</i>, except perhaps <a href="qt.html#WindowType-enum">Qt.WindowStaysOnTopHint</a>.</p> <h3 class="fn"><a name="QSplashScreen-2" />QSplashScreen.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>parent</i>, <a href="qpixmap.html">QPixmap</a> <i>pixmap</i> = QPixmap(), <a href="qt-windowflags.html">Qt.WindowFlags</a> <i>flags</i> = 0)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>This is an overloaded function.</p> <p>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 <i>parent</i>.</p> <h3 class="fn"><a name="clearMessage" />QSplashScreen.clearMessage (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void clearMessage()</tt>.</p><p>Removes the message being displayed on the splash screen</p> <p><b>See also</b> <a href="qsplashscreen.html#showMessage">showMessage</a>().</p> <h3 class="fn"><a name="drawContents" />QSplashScreen.drawContents (<i>self</i>, <a href="qpainter.html">QPainter</a> <i>painter</i>)</h3><p>Draw the contents of the splash screen using painter <i>painter</i>. The default implementation draws the message passed by <a href="qsplashscreen.html#showMessage">showMessage</a>(). Reimplement this function if you want to do your own drawing on the splash screen.</p> <h3 class="fn"><a name="event" />bool QSplashScreen.event (<i>self</i>, <a href="qevent.html">QEvent</a> <i>e</i>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p> <h3 class="fn"><a name="finish" />QSplashScreen.finish (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>w</i>)</h3><p>Makes the splash screen wait until the widget <i>mainWin</i> is displayed before calling <a href="qwidget.html#close">close</a>() on itself.</p> <h3 class="fn"><a name="mousePressEvent" />QSplashScreen.mousePressEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#mousePressEvent">QWidget.mousePressEvent</a>().</p> <h3 class="fn"><a name="pixmap" /><a href="qpixmap.html">QPixmap</a> QSplashScreen.pixmap (<i>self</i>)</h3><p>Returns the pixmap that is used in the splash screen. The image does not have any of the text drawn by <a href="qsplashscreen.html#showMessage">showMessage</a>() calls.</p> <p><b>See also</b> <a href="qsplashscreen.html#setPixmap">setPixmap</a>().</p> <h3 class="fn"><a name="repaint" />QSplashScreen.repaint (<i>self</i>)</h3><p>This overrides <a href="qwidget.html#repaint">QWidget.repaint</a>(). It differs from the standard repaint function in that it also calls <a href="qcoreapplication.html#flush">QApplication.flush</a>() to ensure the updates are displayed, even when there is no event loop present.</p> <h3 class="fn"><a name="setPixmap" />QSplashScreen.setPixmap (<i>self</i>, <a href="qpixmap.html">QPixmap</a> <i>pixmap</i>)</h3><p>Sets the pixmap that will be used as the splash screen's image to <i>pixmap</i>.</p> <p><b>See also</b> <a href="qsplashscreen.html#pixmap">pixmap</a>().</p> <h3 class="fn"><a name="showMessage" />QSplashScreen.showMessage (<i>self</i>, QString <i>message</i>, int <i>alignment</i> = Qt.AlignLeft, <a href="qcolor.html">QColor</a> <i>color</i> = Qt.black)</h3><p>This method is also a Qt slot with the C++ signature <tt>void showMessage(const QString&,int = Qt.AlignLeft,const QColor& = Qt.black)</tt>.</p><p>Draws the <i>message</i> text onto the splash screen with color <i>color</i> and aligns the text according to the flags in <i>alignment</i>.</p> <p>To make sure the splash screen is repainted immediately, you can call <a href="qcoreapplication.html">QCoreApplication</a>'s <a href="qcoreapplication.html#processEvents">processEvents()</a> after the call to showMessage(). You usually want this to make sure that the message is kept up to date with what your application is doing (e.g., loading files).</p> <p><b>See also</b> <a href="qt.html#AlignmentFlag-enum">Qt.Alignment</a> and <a href="qsplashscreen.html#clearMessage">clearMessage</a>().</p> <hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="messageChanged" />void messageChanged (const QString&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the message on the splash screen changes. <i>message</i> is the new message and is a null-string when the message has been removed.</p> <p><b>See also</b> <a href="qsplashscreen.html#showMessage">showMessage</a>() and <a href="qsplashscreen.html#clearMessage">clearMessage</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>