Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QML Timer and Loader

    QML and Qt Quick
    timer loader component qml
    3
    3
    1413
    Loading More Posts
    • 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.
    • M
      Mark81 last edited by

      Qt5.7.0, QtQuick2.0, simple QML page with a Loader:

      Item {
      
          Loader { 
              id: pageLoader 
              asynchronous: true
          }
      
          Component.onCompleted {
              pageLoader.source = "Page1.qml"
          }
      }
      

      Page1.qml contains a Timer:

      Timer {
              interval: 1000
              repeat: true
              running: true
              triggeredOnStart: true
              onTriggered: console.debug(".")
          }
      

      But when I load the page inside the Loader the Timer won't fire.
      What am I missing here?

      1 Reply Last reply Reply Quote 0
      • ?
        A Former User last edited by

        Hi! I'm not 100% sure but I think the problem is that, using an asynchronous Loader, the Timer is created and started on a different thread but this thread has no event loop.

        1 Reply Last reply Reply Quote 0
        • p3c0
          p3c0 Moderators last edited by

          @Mark81 The example works. Is there anything else that is missing ?

          157

          1 Reply Last reply Reply Quote 0
          • First post
            Last post