Important: Please read the Qt Code of Conduct -

Load QML window asynchronous

  • Hi all

    Since loading of my QML app take some time I would to show a splashscreen with an animation just for show the app is alive. The problem is loading of QML from C++ side lock the main message cycle and doesn't allow to update the animation into splashscreen. I tried to set QML object loading using QQmlComponent::Asynchronous param but the next call to create object is still blocking:

    QQmlEngine QmlEngine;
    QQmlComponent MainComponent(&QmlEngine);
    MainComponent.loadUrl(QUrl("qrc:/Main.qml"), QQmlComponent::Asynchronous);
    MainComponent.create(); // <-- this call doesn't return until QML window created

    Using QQmlIncubator and QQmlIncubationController doesn't help and the QML loading return errors (I suspect the problem came from the large quantity of QML compinent and resource to load).

    I still didn't find a way to make asynchronous all the steps of QML loading and creation. Also making the splahscreen using QML and loading the main app window using Loader with asynchronous flag set to true show the same problem, all locks for some seconds before show the main app window (animation too).

    Someone can suggest an alterative way for this issue?
    Thank you

  • Nobody have suggestion? I have to suppose is currently impossible with current implementation of QML to get such result...

  • Moderators

    @Suppaman First why does QML takes so much time to load ?
    Can you lazy load some of the non essential items ?

  • Yes, I could but this is not what I asked for. I'm looking for a way to make anitmated splahscreen since it would be an useful feature for my app. I'm very close to the solution, QML code optimization will come later. My app load a lot of svg images and this take time, all the images have to be ready to show when user start to use the app.

  • If someother is interested in same topic here there is a working solution:

Log in to reply