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. Using Qt.callLater ?
QtWS25 Last Chance

Using Qt.callLater ?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 3.8k 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.
  • A Offline
    A Offline
    Anita
    wrote on last edited by
    #1

    Is it safe to use Qt.callLater? Does it have any disadvantages?
    Eg: If i have one QML which loads another QML using loader. Can I provide the source of the loader using a Qt.callLater Function?

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      https://doc.qt.io/qt-5/qml-qtqml-qt.html#callLater-method

      What is your criteria for "safe"?

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Anita
        wrote on last edited by
        #3

        Hi @fcarney,

        So in My application there are multiple UI updates that happen, so when i want to open a page(Like a Menu), i would like to open the Menu, Just by loading the Title Bar first and the contents of the Menu just after, without any visible Glitch.

        So i would load the TitleBar and on the component.oncompleted of the TitleBar, i would perform a callLater for the contents of the same.

        So my question is : When i write callLater to load the contents of the page under the Title bar, will it occur immediately after the titlebar or will the operation be puushed to the end of the Events queue, due to which i could possibly see a visible delay? Currently in my application i do not see any delay, but in case of long runs/ heavy operations , is it possible that there might be a delay?

        1 Reply Last reply
        0
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          You will have to test this by loading your system. The next event loop iteration might be milliseconds away. You will have to read up on the event loop as to how long that is and if that is acceptable.

          C++ is a perfectly valid school of magic.

          1 Reply Last reply
          0
          • fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by
            #5

            I wonder why you are using Component.onCompleted to load data? I would think a demand driven model based upon QAbstractListModel/ItemModel might be better.

            C++ is a perfectly valid school of magic.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Anita
              wrote on last edited by
              #6

              Hi @fcarney ,
              Yes I will check the same . Thank you for the Input.

              No Actually I am loading another qml on the completion of the load of a titlebar page.
              So My QMl looks like :
              Menu.qml{
              Rectangle{
              id:titleRect
              .
              .
              Text{
              .
              .
              .
              }
              }
              Loader{
              id:loadId
              anchors.top : titleRect.bottom

              }
              function setSource()
              {
              loadId.source = "Menu_Page1.qml"
              }
              Component.onCompleted:{
              Qt.callLater(setSource)
              }
              }

              @fcarney : Thanks for your inputs. :)

              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