• May 01, 2024, 09:17:42 pm

Author Topic: How to: Qt Splashscreen for QML/Qt apps  (Read 8455 times)

0 Members and 1 Guest are viewing this topic.

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
How to: Qt Splashscreen for QML/Qt apps
« on: March 25, 2013, 12:03:00 am »
Hi
I tried to make an QML Splashscreen, it worked fine but I think this isn't the best way.

After research I figured out how to use a Qt Splashscreen, everything is inside of main.cpp:

- you have to import:

Code: [Select]
#include <QtGui/QSplashScreen>
#include <QtGui/QPixmap>

than edit your main method:
(you have to add this part before the QmlApplication viewer)

Code: [Select]
QSplashScreen *splash = new QSplashScreen(QPixmap(":/splash/splash.jpg"));
    splash->show();

than after the viewer code put:

Code: [Select]
splash->finish(&viewer);
splash->deleteLater();

of course before the "return app->exec();"


This will brick the Qt Simulator, so comment this parts if you test your app!

the path ":/splash/splash.jpg" is for qrc, so add:
Code: [Select]
<RCC>
    <qresource prefix="/">
        <file>splash/splash.jpg</file>
    </qresource>
</RCC>
to your qrc file.


The best picture size is 640*640, because the picture get's croped (depending on your devices orientation)

I attached an example.

Sources:
http://harmattan-dev.nokia.com/docs/library/html/qt4/qsplashscreen.html?tab=3&q=splash&sp=all
https://github.com/dicksonleong/GagBook

[attachment deleted by admin]
« Last Edit: March 25, 2013, 12:21:18 am by huellif »

Offline symster

  • Developer
  • Happy Member
  • ****
  • Posts: 214
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : Nokia N8 Soon Nokia 808
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #1 on: February 08, 2014, 01:28:37 pm »
More tips.To prevent users from accidentally closing the splashscreen when they touch the screen,add the code below.With this even when users touch the screen,the splashscreen will still show instead of disappear when touched.

Code: [Select]
splash->setEnabled(false);
« Last Edit: February 09, 2014, 10:13:43 am by symster »

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #2 on: February 10, 2014, 12:03:14 am »
are you sure it's needed with Qt 4.8?
For me touching the splashscreen does nothing.

Offline symster

  • Developer
  • Happy Member
  • ****
  • Posts: 214
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : Nokia N8 Soon Nokia 808
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #3 on: February 10, 2014, 09:51:46 am »
Well for my n8 belle refresh it is needed.Without this line,the splashscreen disappear when touched.Tested few times so it is confirm.

Offline matthew

  • Mass Poster
  • ****
  • Posts: 1,315
  • Reputation: 13
  • SymphonyOS
  • Current Phone: :
    N8-00 (25.007)
    808 (113.010.1508)
    Retired E72, E6-00
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #4 on: February 10, 2014, 07:12:12 pm »
It seems to do the same in Anna; but i only have a few Qt apps with splashscreens so i have little testing to back that statement.

Offline symster

  • Developer
  • Happy Member
  • ****
  • Posts: 214
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : Nokia N8 Soon Nokia 808
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #5 on: February 10, 2014, 08:04:32 pm »
It seems to do the same in Anna; but i only have a few Qt apps with splashscreens so i have little testing to back that statement.
You mean your app have splashscreen disappear when touched or i misunderstood what you wrote.

Offline matthew

  • Mass Poster
  • ****
  • Posts: 1,315
  • Reputation: 13
  • SymphonyOS
  • Current Phone: :
    N8-00 (25.007)
    808 (113.010.1508)
    Retired E72, E6-00
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #6 on: February 10, 2014, 08:51:24 pm »
Well, i installed a few more to test and it seems that this is inconclusive.
Some can be closed by touch and some can not.
i am aware of the difference between a loading screen and a splashscreen, too, so it's not a question of misunderstanding here.

Offline symster

  • Developer
  • Happy Member
  • ****
  • Posts: 214
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : Nokia N8 Soon Nokia 808
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #7 on: February 10, 2014, 09:15:09 pm »
Well the app you test,does it use qt or qml splashscreen?.Anyway it could be just due different qt versiom only.I don't really understand what you mean inconclusive.Maybe some developers do the method above and some don't.

Offline matthew

  • Mass Poster
  • ****
  • Posts: 1,315
  • Reputation: 13
  • SymphonyOS
  • Current Phone: :
    N8-00 (25.007)
    808 (113.010.1508)
    Retired E72, E6-00
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #8 on: February 10, 2014, 09:18:46 pm »
Well the app you test,does it use qt or qml splashscreen?.Anyway it could be just due different qt versiom only.I don't really understand what you mean inconclusive.Maybe some developers do the method above and some don't.
Inconclusive means not conclusive. Not able to be concluded.
ie, the results were mixed and i haven't read any of the QML so i can't say for certain one way or another about the splash.

Offline matthew

  • Mass Poster
  • ****
  • Posts: 1,315
  • Reputation: 13
  • SymphonyOS
  • Current Phone: :
    N8-00 (25.007)
    808 (113.010.1508)
    Retired E72, E6-00
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #9 on: February 10, 2014, 09:20:52 pm »
^(And i am still a bit shaky with QML. i haven't found it as easy to read as some other code.)^

Offline symster

  • Developer
  • Happy Member
  • ****
  • Posts: 214
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : Nokia N8 Soon Nokia 808
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #10 on: February 10, 2014, 09:56:27 pm »
^(And i am still a bit shaky with QML. i haven't found it as easy to read as some other code.)^

I even took 2month just to understand the syntax but once you know the way it is easier than c++ which is prone to syntax error

Offline matthew

  • Mass Poster
  • ****
  • Posts: 1,315
  • Reputation: 13
  • SymphonyOS
  • Current Phone: :
    N8-00 (25.007)
    808 (113.010.1508)
    Retired E72, E6-00
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #11 on: February 10, 2014, 10:06:30 pm »
http://harmattan-dev.nokia.com/docs/library/html/qt4/qsplashscreen.html?tab=3&q=splash&sp=all returns:
Quote
An error occurred while processing your request.
Reference #97.e9e90cc3.1392051768.1bd27b70

Offline symster

  • Developer
  • Happy Member
  • ****
  • Posts: 214
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : Nokia N8 Soon Nokia 808
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #12 on: February 10, 2014, 10:16:58 pm »
Harmattan online documentation is no longer available since they reshuffle nokia developer.Now they only provide offline document at http://developer.nokia.com/resources/download/4255/?id=4255 and the wiki http://developer.nokia.com/resources/download/4255/?id=4255 .If you are more active in harmattan then this site is probably more suitable http://talk.maemo.org/ .This is where all great developers like burning plaform and cutetube dev active

Offline matthew

  • Mass Poster
  • ****
  • Posts: 1,315
  • Reputation: 13
  • SymphonyOS
  • Current Phone: :
    N8-00 (25.007)
    808 (113.010.1508)
    Retired E72, E6-00
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #13 on: February 10, 2014, 10:19:39 pm »
@symster Thanks for the links, mate.

Offline symster

  • Developer
  • Happy Member
  • ****
  • Posts: 214
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : Nokia N8 Soon Nokia 808
Re: How to: Qt Splashscreen for QML/Qt apps
« Reply #14 on: February 10, 2014, 10:27:07 pm »
 ;)