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 and Loader
QtWS25 Last Chance

QML Timer and Loader

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
timerloadercomponentqml
3 Posts 3 Posters 1.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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    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
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      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
      1
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

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

        157

        1 Reply Last reply
        1

        • Login

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