Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Stop QQuickView showing before QML is rendered?
Forum Update on Monday, May 27th 2025

Stop QQuickView showing before QML is rendered?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 194 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tummon
    wrote on last edited by
    #1

    Hi, I have the following scenario

    main.qml:

    //very slow QML code :)
    

    main.cpp

    QQuickView v(QStringLiteral("qrc:/main.qml"));
    v.show();
    

    The QQuickView shows a blank white screen briefly before the QML is loaded.
    Is there anyway to prevent the view from showing until the QML is rendering?

    The QML scene graph does not get initialized until after QQuickView is shown, I would like a way to have everything ready to go before hand.

    Current hacky solution is to set the view opacity to 0 until QQuickWindow::afterRendering is fired.

    Unfortunately tidying up the slow QML code isn't an option right now...

    Thanks in advance!

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kamichanw
      wrote on last edited by
      #2

      Since you didn't provide more information, I can only give you some advice based on experience.
      I'm not sure about your qt version. If you a using qt 5.1(and higher), you should try QQmlApplicationEngine. Here is an example

      QQmlApplicationEngine engine;
      const QUrl url(u"qrc:/MainForm.qml"_qs);
      QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) {
          if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
      }, Qt::QueuedConnection);
      engine.load(url);
      
      T 1 Reply Last reply
      0
      • K Kamichanw

        Since you didn't provide more information, I can only give you some advice based on experience.
        I'm not sure about your qt version. If you a using qt 5.1(and higher), you should try QQmlApplicationEngine. Here is an example

        QQmlApplicationEngine engine;
        const QUrl url(u"qrc:/MainForm.qml"_qs);
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
              QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
        engine.load(url);
        
        T Offline
        T Offline
        Tummon
        wrote on last edited by
        #3

        @Kamichanw Sorry, using 5.15.2 but moving to 6.5.x in the next couple of months

        To give more info we are using multiple QQuickViews and QQuickWidgets, that share the one QQmlEngine instance.

        I'm not sure if using multiple QQmlApplicationEngines is an alternative

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved