<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QSplashScreen logic Issues]]></title><description><![CDATA[<p dir="auto">I am developing a Qt Application on Linux and seem to have some issues grasping the QSplashScreen class. What I'm trying to accomplish is a splash screen with status updates, such as loading in configurations, building menus, etc. How I'm going about it is in main.cpp I declare the splash screen and write the first message to it, then process some code to load in a configuration, then update the splash screen with a new message and process some more code. then I declare a mainwindow, build its contents, show it and call app.exec();  What seams to be happening is the splash screen isn't displayed until the app.exec is called and by then all the code has run which results in the splash screen being displayed for about a half second then the main window appears and the splash vanishes.</p>
<p dir="auto">Any ideas on the logical approach towards this functionality of a Qt Program?</p>
<p dir="auto">Thanks in advance...</p>
]]></description><link>https://forum.qt.io/topic/37788/qsplashscreen-logic-issues</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 22:48:00 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/37788.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 13 Feb 2014 17:13:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QSplashScreen logic Issues on Sat, 15 Feb 2014 23:40:06 GMT]]></title><description><![CDATA[<p dir="auto">Here is a sample of the code I'm using...</p>
<p dir="auto">From main.cpp</p>
<p dir="auto">@<br />
#include "mainwindow.h"<br />
#include &lt;QApplication&gt;<br />
#include &lt;QSplashScreen&gt;<br />
#include "testsplashscreen.h"</p>
<p dir="auto">int main(int argc, char *argv[])<br />
{<br />
QApplication a(argc, argv);</p>
<pre><code>testSplashScreen *splashScreen = new testSplashScreen();
splashScreen-&gt;setPixmap(QPixmap(":/loading.gif"));
splashScreen-&gt;setTextArea(QRect(210, 145, 400, 57));
splashScreen-&gt;show();
QFont splashFont;
splashFont.setFamily("Ariel");
splashFont.setPixelSize(10);
splashScreen-&gt;setFont(splashFont);
qApp-&gt;processEvents();
splashScreen-&gt;setTextMessage(QObject::tr("Initializing....."), Qt::white);
// Load Configuration files here...
splashScreen-&gt;setTextMessage(QObject::tr("Building Menu...."), Qt::white);
// build gui 
qApp-&gt;processEvents();
MainWindow w;
w.show();
splashScreen-&gt;finish(&amp;w);
return a.exec&amp;#40;&amp;#41;;
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">From  mainwindow.cpp</p>
<p dir="auto">@<br />
#include "mainwindow.h"</p>
<p dir="auto">MainWindow::MainWindow(QWidget *parent)<br />
: QMainWindow(parent)<br />
{<br />
}</p>
<p dir="auto">MainWindow::~MainWindow()<br />
{</p>
<p dir="auto">}<br />
@</p>
<p dir="auto">From testsplashscreen.cpp<br />
@<br />
#include "testsplashscreen.h"<br />
#include &lt;QPainter&gt;</p>
<p dir="auto">testSplashScreen::testSplashScreen(QWidget *parent) : QSplashScreen(parent)<br />
{<br />
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::SplashScreen);<br />
}</p>
<p dir="auto">void testSplashScreen::setTextArea(QRect Area, int Alignment)<br />
{<br />
splashRect = Area;<br />
Alignment  = Alignment;<br />
}</p>
<p dir="auto">void testSplashScreen::setTextMessage(QString message, QColor color)<br />
{<br />
splashMessage = message;<br />
splashColor   = color;<br />
showMessage(splashMessage, splashAlignment, splashColor);<br />
}</p>
<p dir="auto">void testSplashScreen::drawContents(QPainter *painter)<br />
{<br />
painter-&gt;setPen(splashColor);<br />
painter-&gt;drawText(splashRect, splashAlignment, splashMessage);<br />
}<br />
@</p>
<p dir="auto">From testsplashscreen.h</p>
<p dir="auto">@<br />
#include "testsplashscreen.h"<br />
#include &lt;QPainter&gt;</p>
<p dir="auto">testSplashScreen::testSplashScreen(QWidget *parent) : QSplashScreen(parent)<br />
{<br />
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::SplashScreen);<br />
}</p>
<p dir="auto">void testSplashScreen::setTextArea(QRect Area, int Alignment)<br />
{<br />
splashRect = Area;<br />
Alignment  = Alignment;<br />
}</p>
<p dir="auto">void testSplashScreen::setTextMessage(QString message, QColor color)<br />
{<br />
splashMessage = message;<br />
splashColor   = color;<br />
showMessage(splashMessage, splashAlignment, splashColor);<br />
}</p>
<p dir="auto">void testSplashScreen::drawContents(QPainter *painter)<br />
{<br />
painter-&gt;setPen(splashColor);<br />
painter-&gt;drawText(splashRect, splashAlignment, splashMessage);<br />
}<br />
@</p>
<p dir="auto">From mainwindow.h</p>
<p dir="auto">@<br />
#ifndef MAINWINDOW_H<br />
#define MAINWINDOW_H</p>
<p dir="auto">#include &lt;QMainWindow&gt;</p>
<p dir="auto">class MainWindow : public QMainWindow<br />
{<br />
Q_OBJECT</p>
<p dir="auto">public:<br />
MainWindow(QWidget *parent = 0);<br />
~MainWindow();<br />
};</p>
<p dir="auto">#endif // MAINWINDOW_H<br />
@</p>
<p dir="auto">From <a href="http://splashScreen.pro" target="_blank" rel="noopener noreferrer nofollow ugc">splashScreen.pro</a><br />
@<br />
#-------------------------------------------------</p>
<h1></h1>
<h1>Project created by QtCreator 2014-02-15T13:52:27</h1>
<h1></h1>
<p dir="auto">#-------------------------------------------------</p>
<p dir="auto">QT       += core gui</p>
<p dir="auto">greaterThan(QT_MAJOR_VERSION, 4): QT += widgets</p>
<p dir="auto">TARGET = splashScreen<br />
TEMPLATE = app</p>
<p dir="auto">SOURCES += main.cpp<br />
mainwindow.cpp <br />
testsplashscreen.cpp</p>
<p dir="auto">HEADERS  += mainwindow.h <br />
testsplashscreen.h</p>
<p dir="auto">RESOURCES += <br />
testSplashScreen.qrc<br />
@</p>
<p dir="auto">This code will demonstrate the issues I'm having, if the splash screen is even displayed its for just a flash less than 1/2 second. The problem is that all the processing is completed before the screen will show. If you comment out the a.exec(); then absoulutely nothing is displayed at all which indicates that the QSplashScreen does not perform until the apps exec function is called.</p>
<p dir="auto">Thanks for the help.</p>
]]></description><link>https://forum.qt.io/post/215033</link><guid isPermaLink="true">https://forum.qt.io/post/215033</guid><dc:creator><![CDATA[Chrisw01]]></dc:creator><pubDate>Sat, 15 Feb 2014 23:40:06 GMT</pubDate></item><item><title><![CDATA[Reply to QSplashScreen logic Issues on Sat, 15 Feb 2014 21:43:04 GMT]]></title><description><![CDATA[<p dir="auto">Then build it ! :)</p>
<p dir="auto">More seriously, it should indeed work calling only processEvents().</p>
<p dir="auto">Do you have the same behavior with documentation's example ?</p>
]]></description><link>https://forum.qt.io/post/215017</link><guid isPermaLink="true">https://forum.qt.io/post/215017</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 15 Feb 2014 21:43:04 GMT</pubDate></item><item><title><![CDATA[Reply to QSplashScreen logic Issues on Fri, 14 Feb 2014 23:52:37 GMT]]></title><description><![CDATA[<p dir="auto">I thought about that, but after reading the horror stories on upgrading to 5.2.x on ubuntu I chickened out.</p>
<p dir="auto">I've done some more testing, if I comment out the code to create the main window and basically draw the splash screen and exit it works as expected messages get updated, etc, however if I comment out app.exec() then the splace screen does not display. I'm not sure if its a bug in 5.2.0, a design flaw in the splash code logic or I can't just wrap my head around it but IMO the splash screen should be able to be displayed and updated by calling app.processevents(); whether or not app.exec(); has been called or not. I'll post more when I get 5.2.x installed.</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.qt.io/post/214948</link><guid isPermaLink="true">https://forum.qt.io/post/214948</guid><dc:creator><![CDATA[Chrisw01]]></dc:creator><pubDate>Fri, 14 Feb 2014 23:52:37 GMT</pubDate></item><item><title><![CDATA[Reply to QSplashScreen logic Issues on Fri, 14 Feb 2014 21:10:12 GMT]]></title><description><![CDATA[<p dir="auto">You can also install the binary package to try with 5.2.1</p>
]]></description><link>https://forum.qt.io/post/214934</link><guid isPermaLink="true">https://forum.qt.io/post/214934</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 14 Feb 2014 21:10:12 GMT</pubDate></item><item><title><![CDATA[Reply to QSplashScreen logic Issues on Fri, 14 Feb 2014 16:38:00 GMT]]></title><description><![CDATA[<p dir="auto">Hi, and thanks for your reply, I have calls to the processEvents() in the code, what appears to be happening is the splash screen is not being displayed until the app.exec is called which by then it's to late because all the previous code with splashScreen messages have already ran and completed.</p>
<p dir="auto">End result, the code works, however the splash screen is only displayed for maybe a 1/2 second and dissapears due to splashScreen.finish(); I assume.</p>
<p dir="auto">Further note, I am running ubuntu 13.10 which installs 5.0.2, 14.04 is due out in a few weeks which pushes the 5.2.x series maybe I'll force the update to see if by chances its a glitch that has been fixed already.</p>
<p dir="auto">Thanks again.</p>
]]></description><link>https://forum.qt.io/post/214911</link><guid isPermaLink="true">https://forum.qt.io/post/214911</guid><dc:creator><![CDATA[Chrisw01]]></dc:creator><pubDate>Fri, 14 Feb 2014 16:38:00 GMT</pubDate></item><item><title><![CDATA[Reply to QSplashScreen logic Issues on Thu, 13 Feb 2014 22:02:51 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">From the docs</p>
<p dir="auto">@<br />
QApplication app(argc, argv);<br />
QPixmap pixmap(":/splash.png");<br />
QSplashScreen splash(pixmap);<br />
splash.show();<br />
app.processEvents(); &lt;&lt; this is what you might be missing<br />
...<br />
QMainWindow window;<br />
window.show();<br />
splash.finish(&amp;window);<br />
return app.exec();@</p>
<p dir="auto">Hope it helps</p>
]]></description><link>https://forum.qt.io/post/214796</link><guid isPermaLink="true">https://forum.qt.io/post/214796</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 13 Feb 2014 22:02:51 GMT</pubDate></item></channel></rss>