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. QML Timer is blocked?
Forum Updated to NodeBB v4.3 + New Features

QML Timer is blocked?

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 3.8k Views 1 Watching
  • 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

    I want to use a repeated QML timer to show a rotating cursor when the user interface thread is blocked ( for example when loading a big QML file ). The timer is not trigger:

    @
    Item {
    property bool doSomething: false

    Timer {
         interval: 500; running: doSomething; repeat: true
         onTriggered: console.log("triggered")
    }
    
    Loader {
      id: bigLoader
      source: doSomething ? "big.qml" : ""
    

    }
    }
    @

    When I set doSomething to true the qml is loaded but the timer is not triggered...

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dmcr
      wrote on last edited by
      #2

      did you try to give an id to your Timer, then start it width
      @idTimer.start()@ when you change the doSometing^^ boolean ?

      dmcr

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

        Does not work when the Loader is loading the big page. When it's done the timer is triggered (but this also worked in the previous example).
        @
        Item {
        property bool doSomething
        onDoSomethingChanged: doSomething ? timer.start() : timer.stop()

                 Loader {
                             source: doSomething ? " big.qml" : ""
                 }
        

        Timer {
        id: timer
        interval: 1000; running: false; repeat: true
        onTriggered: { console.log("triggered") }
        }
        }
        @

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbrasser
          wrote on last edited by
          #4

          Hi,

          The issue in this case is that Loader loads the QML on the main thread (effectively blocking it), which the Timer is also running on. This has been addressed in QtQuick 2.0 via the asynchronous property added to Loader (which allows animations to run while the loading happens).

          Regards,
          Michael

          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