How to create a splash screen with an induced delay: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Convert ExpressionEngine links)
(Convert ExpressionEngine section headers)
Line 1: Line 1:
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}


h1. How to create a splash screen with an induced delay.
= How to create a splash screen with an induced delay. =
 
We have [http://doc.qt.nokia.com/latest/qsplashscreen.html QSplashScreen] which is used to cover up the starting delay of the program. More about splash screen is [http://doc.qt.nokia.com/latest/qsplashscreen.html here].
We have [http://doc.qt.nokia.com/latest/qsplashscreen.html QSplashScreen] which is used to cover up the starting delay of the program. More about splash screen is [http://doc.qt.nokia.com/latest/qsplashscreen.html here].
Some times the programs might be quick enough ,so that the splash screen may not be visible. We may induce some delay to show the splash , as a decoration !
Some times the programs might be quick enough ,so that the splash screen may not be visible. We may induce some delay to show the splash , as a decoration !

Revision as of 16:00, 5 March 2015

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

How to create a splash screen with an induced delay.

We have QSplashScreen which is used to cover up the starting delay of the program. More about splash screen is here. Some times the programs might be quick enough ,so that the splash screen may not be visible. We may induce some delay to show the splash , as a decoration !

Here in this example, using QThread a delay is induced.

#include <QApplication>
#include <QSplashScreen>
#include <qthread.h>
#include "mainwindow.h"

class I : public QThread
{
public:
 static void sleep(unsigned long secs) {
 QThread::sleep(secs);
 }
};

int main(int argc, char *argv[])
{

QApplication app(argc, argv);
 QPixmap pixmap("splash.jpg");
 QSplashScreen splash(pixmap);
 splash.show();
 MainWindow mainWin;
 mainWin.setWindowTitle("Application");
 I::sleep(5); // splash is shown for 5 seconds
 mainWin.showMaximized();
 splash.finish(&amp;mainWin);
 return app.exec();
}

Easy! Happy coding!