Discussion:
Showing animated progress while loading large QML files
Pelle Johnsen
2011-01-12 11:08:20 UTC
Permalink
Hi,

I'm working on a QML based app. where I dynamically load 'sub' applications
or plugins at runtime. However when running on maemo, loading of all the QML
files of such a sub-app. takes quite a long time (5-10 secs, enough for the
end user to be annoyed), so I'm wondering if there is a way to at least show
an animated loading screen while this is going on. I've tried a couple of
things, but haven't really found a satisfying solution:

- Wrap the QML in a Loader: This allows me to show a static loading screen,
but as soon as I ask the loader to load the rest of the QML content, all
animation is blocked while it's loading.
- Load the QML in a background thread: This fails because the QML contains
a lot of images which in turn creates QPixmaps, which doesn't work from
another thread than the main ui thread :(

I've done a number of things to speed up the actual loading itself, but I
don't think I can get it much faster:

- Prefetch the QML, i.e. have the QML engine load the same QML file so it
caches the parsed version of the QML
- Prefetch images, i.e. have the image loaded into QPixmapCache ahead of
time

Any help appreciated,

-Pelle
Yuvraaj Kelkar
2011-01-12 17:18:43 UTC
Permalink
Just a thought, don't know if it will work for you:
Is it possible for you to begin loading the sub-qml in an Item with
opacity:0 while you show a Rectangle (opacity:1) with Text?
Then once you get the signal that the sub-QML is loaded,
PropertyChanges can switch opacities.
Post by Pelle Johnsen
Hi,
I'm working on a QML based app. where I dynamically load 'sub' applications
or plugins at runtime. However when running on maemo, loading of all the QML
files of such a sub-app. takes quite a long time (5-10 secs, enough for the
end user to be annoyed), so I'm wondering if there is a way to at least show
an animated loading screen while this is going on. I've tried a couple of
 - Wrap the QML in a Loader: This allows me to show a static loading screen,
but as soon as I ask the loader to load the rest of the QML content, all
animation is blocked while it's loading.
 - Load the QML in a background thread: This fails because the QML contains
a lot of images which in turn creates QPixmaps, which doesn't work from
another thread than the main ui thread :(
I've done a number of things to speed up the actual loading itself, but I
 - Prefetch the QML, i.e. have the QML engine load the same QML file so it
caches the parsed version of the QML
 - Prefetch images, i.e. have the image loaded into QPixmapCache ahead of
time
Any help appreciated,
 -Pelle
_______________________________________________
Qt-qml mailing list
http://lists.qt.nokia.com/mailman/listinfo/qt-qml
Pelle Johnsen
2011-01-12 17:26:15 UTC
Permalink
Thanks for the suggestion, as mentioned I've managed to encapsulate the
'heavy' QML in a Loader and thus display a static loading screen (an image
an the text 'Loading ...').

However I want to show an animated spinner, or similar to let the end user
know the app is still alive (ideally I would like to show a progress bar).
The problem is that when the Loader starts loading the rest of the QML it
freezes up the whole ui thread, so it's impossible to refresh the screen
with any progress info or even just run an animation. The QML files are
loaded from a resource file (.RCC) if it makes any difference.
Post by Yuvraaj Kelkar
Is it possible for you to begin loading the sub-qml in an Item with
opacity:0 while you show a Rectangle (opacity:1) with Text?
Then once you get the signal that the sub-QML is loaded,
PropertyChanges can switch opacities.
Yuvraaj Kelkar
2011-01-12 17:48:55 UTC
Permalink
Ah I see. Maemo has a platform specific flag to show a spinning wheel
on the title bar (Qt::WA_Maemo5ShowProgressIndicator) but thats only
useful if your window is not fullscreen.
Also I'm not sure if it spins if the QT event loop is stuck like in your case.

One possible hack would be to spawn a helper process (thus a different
GUI event loop) and show a message.
Thanks for the suggestion, as mentioned I've managed to encapsulate the
'heavy' QML in a Loader and thus display a static loading screen (an image
an the text 'Loading ...').
However I want to show an animated spinner, or similar to let the end user
know the app is still alive (ideally I would like to show a progress bar).
The problem is that when the Loader starts loading the rest of the QML it
freezes up the whole ui thread, so it's impossible to refresh the screen
with any progress info or even just run an animation. The QML files are
loaded from a resource file (.RCC) if it makes any difference.
Post by Yuvraaj Kelkar
Is it possible for you to begin loading the sub-qml in an Item with
opacity:0 while you show a Rectangle (opacity:1) with Text?
Then once you get the signal that the sub-QML is loaded,
PropertyChanges can switch opacities.
_______________________________________________
Qt-qml mailing list
http://lists.qt.nokia.com/mailman/listinfo/qt-qml
Pelle Johnsen
2011-01-12 17:56:40 UTC
Permalink
Thanks, actually I'm only using maemo for testing. The end target is a
custom embedded linux platform (arm based, probably using QWS).

So I kind of need a solution in the app. itself. Currently I'm looking at
rendering a spinner from another thread using opengl, and so far it looks
promising :)
Post by Yuvraaj Kelkar
Ah I see. Maemo has a platform specific flag to show a spinning wheel
on the title bar (Qt::WA_Maemo5ShowProgressIndicator) but thats only
useful if your window is not fullscreen.
Also I'm not sure if it spins if the QT event loop is stuck like in your case.
One possible hack would be to spawn a helper process (thus a different
GUI event loop) and show a message.
Loading...