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. When QML Loader is loading a file show a wait dialog
QtWS25 Last Chance

When QML Loader is loading a file show a wait dialog

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 3 Posters 7.7k 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.
  • B Offline
    B Offline
    bkamps
    wrote on last edited by
    #1

    Hi,

    I have a pretty slow embedded target device and some QML files that I want to load dynamically. To load them dynamically I use QML Loader:

    @
    Loader {
    source: "pretty_big.qml"
    }
    @

    When the pretty_big QML is loading I want to show a dialog telling the user the window is being loaded. There is no need for a animation I just want to show a dialog.

    How to archieve this?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      I have tried this many times and failed so far. You can have a go, if you want :) In theory, Loader has the "progress" property that can be used to get to know how it is doing. In practice, the property is not being updated too often - in my tests it went straight from 0 to 100%.

      For a dialog, you can also use Loader::status property.

      (Z(:^

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bkamps
        wrote on last edited by
        #3

        I have tried the following:

        @
        Loader {
        id: loader
        source: "pretty_big.qml"
        onStatusChanged: if (status == Loader.Loading) console.log('Loading')
        @

        Guess what: I don't get the Loader.Loading status (no console log seen)....

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bkamps
          wrote on last edited by
          #4

          I read this at QML Loader documentation:

          Note that if the source is a local file, the status will initially be Ready (or Error). While there will be no onStatusChanged signal in that case, the onLoaded will still be invoked.

          I am loading a local qml file, that's probably why I don't get the Loading event....

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            That is probably why I couldn't get it to work, too.

            Just a random thought, but that would be a massive overkill: maybe if you specified the path relative to localhost ("127.0.0.1/myQml.qml") it would fool the Loader into thinking it's a remote file. But that seems just crazy :) It would probably be better to just request this feature from Trolls, or implement ourselves and commit to main qt-project.org.

            (Z(:^

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bkamps
              wrote on last edited by
              #6

              Currently I give the loader a trigger when it should load the QML file:

              @
              Loader {
              source: mycppObj.visible ? "pretty_big.qml" : ""
              }
              @

              Maybe I can somehow first trigger a wait dialog and then trigger the loader to load the qml. When the Loader is READY I hide the wait dialog.

              This all sounds very hackish..... Any suggestions how to do this?

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                @
                Loader {
                function loadFile() // or even better, pass the filename here
                {
                loadingScreen.visible = true;
                loader.loadMe = true;
                }

                property bool loadMe: false
                id: loader
                source: loadMe ? "pretty_big.qml" : ""

                onStatusChanged: if (status == Loader.Ready) loadingScreen.visible = false;
                }

                Rectangle {
                id: loadingScreen
                visible: false
                }
                @

                OK, that's just a quick draft. I have not thought it through, nor tested. Proceed with care :)

                (Z(:^

                1 Reply Last reply
                0
                • EddyE Offline
                  EddyE Offline
                  Eddy
                  wrote on last edited by
                  #8

                  I did something similar by following this "wiki page ":http://www.developer.nokia.com/Community/Wiki/Implementing_a_Splash_Screen_with_Qt_Quick

                  I hope it can help you too.

                  Qt Certified Specialist
                  www.edalsolutions.be

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    bkamps
                    wrote on last edited by
                    #9

                    You mean I need to call the function to load the file and show the splashscreen? I use cpp object and qml property binding to show and hide the window.

                    I have a lot (25) windows, so also 25 loaders. I also bind properties of cpp object and qml properties:

                    @
                    Loader {
                    id: loader
                    source: myCppObject.visible ? "window.qml" : ""
                    Binding { target: loader.item; property: "title"; value: myCppObject.text }
                    }
                    @

                    I think the code will be very ugly if I also put in some function to show a wait dialog.

                    [quote author="sierdzio" date="1339774864"]@
                    Loader {
                    function loadFile() // or even better, pass the filename here
                    {
                    loadingScreen.visible = true;
                    loader.loadMe = true;
                    }

                    property bool loadMe: false
                    id: loader
                    source: loadMe ? "pretty_big.qml" : ""

                    onStatusChanged: if (status == Loader.Ready) loadingScreen.visible = false;
                    }

                    Rectangle {
                    id: loadingScreen
                    visible: false
                    }
                    @

                    OK, that's just a quick draft. I have not thought it through, nor tested. Proceed with care :)[/quote]

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      bkamps
                      wrote on last edited by
                      #10

                      I could use timers... Too bad QtQuick doesn't offer some handy stuff to do something simple like showing a wait dialog...

                      I'll look into it.

                      [quote author="Eddy" date="1339783207"]I did something similar by following this "wiki page ":http://www.developer.nokia.com/Community/Wiki/Implementing_a_Splash_Screen_with_Qt_Quick

                      I hope it can help you too.[/quote]

                      1 Reply Last reply
                      0
                      • sierdzioS Offline
                        sierdzioS Offline
                        sierdzio
                        Moderators
                        wrote on last edited by
                        #11

                        [quote author="bkamps" date="1339785531"]Too bad QtQuick doesn't offer some handy stuff to do something simple like showing a wait dialog...
                        [/quote]

                        Well, with QML still being relatively new, you will have to wait for it (pun very much intended :P). Right now QML consists mostly of the basic building blocks. You are free to take it anywhere, but you have to do the "taking" yourself. Or look into some material from other people, like the desktop components, etc. Over time number of available components and add-ons will grow (if there is enough interest in QML).

                        (Z(:^

                        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