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. Zero-second Timer doesn't run in qmlscene?
Forum Updated to NodeBB v4.3 + New Features

Zero-second Timer doesn't run in qmlscene?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 4 Posters 426 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.
  • P Offline
    P Offline
    patrickkidd
    wrote on last edited by
    #1

    It looks like zero-second timers don't run using the qmlscene exe? The following snippet never prints anything.

    Rectangle {
    
        id: root
    
        Timer {
            interval: 0
            running: true
            repeat: true
            onTriggered: {
                print('here')
            }
        }
    }
    

    https://alaskafamilysystems.com/

    J.HilkJ ODБOïO 2 Replies Last reply
    0
    • P patrickkidd

      It looks like zero-second timers don't run using the qmlscene exe? The following snippet never prints anything.

      Rectangle {
      
          id: root
      
          Timer {
              interval: 0
              running: true
              repeat: true
              onTriggered: {
                  print('here')
              }
          }
      }
      
      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @patrickkidd
      I can't say for sure, but the documentation states:

      The Timer type is synchronized with the animation timer. Since the animation timer is usually set to 60fps, the resolution of Timer will be at best 16ms.
      

      so any interval < 16 doesn't make much sense to begin with.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      P 1 Reply Last reply
      3
      • P patrickkidd

        It looks like zero-second timers don't run using the qmlscene exe? The following snippet never prints anything.

        Rectangle {
        
            id: root
        
            Timer {
                interval: 0
                running: true
                repeat: true
                onTriggered: {
                    print('here')
                }
            }
        }
        
        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by ODБOï
        #3

        @patrickkidd said in Zero-second Timer doesn't run in qmlscene?:

        interval: 0

        if you need to Trigger immediately, QML Timer has triggeredOnStart bool property you can set to true for the first tick,
        otherwise an interval of 0ms makes absolutely no sense

        1 Reply Last reply
        0
        • MarkkyboyM Offline
          MarkkyboyM Offline
          Markkyboy
          wrote on last edited by
          #4

          The code does work, but you need to omit "interval: 0", then it prints in console; "qml: here"

          Don't just sit there standing around, pick up a shovel and sweep up!

          I live by the sea, not in it.

          1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @patrickkidd
            I can't say for sure, but the documentation states:

            The Timer type is synchronized with the animation timer. Since the animation timer is usually set to 60fps, the resolution of Timer will be at best 16ms.
            

            so any interval < 16 doesn't make much sense to begin with.

            P Offline
            P Offline
            patrickkidd
            wrote on last edited by patrickkidd
            #5

            @J-Hilk

            so any interval < 16 doesn't make much sense to begin with.

            Thanks for pointing that out, as it helps in the case that someone is attempting to optimize performance in animations.

            @LeLev

            if you need to Trigger immediately, QML Timer has triggeredOnStart bool property you can set to true for the first tick,
            otherwise an interval of 0ms makes absolutely no sense

            A zero-second timer would be used for wanting something to execute whenever there is idle time in the event loop. This would obviously lock a graphical application, but can be used effectively in short bursts or for discrete worker tasks, or simply to queue a one-off update after the current GUI job is done for example when you want to initialize a component after onCompleted is finished. In these cases you managing the running property to start and top the timer but leave the interval at 0. This is a common use case, especially when there are a lot of bugs in the built-in Qml types (which is often the case) and you are trying to workaround them. triggeredOnStart does not accomplish this as it starts the timer in the same call as setting running = true.

            https://alaskafamilysystems.com/

            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