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. With QML how do I get a timed event that is accurate enough for animating frames of a Canvas
Forum Updated to NodeBB v4.3 + New Features

With QML how do I get a timed event that is accurate enough for animating frames of a Canvas

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 298 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.
  • A Offline
    A Offline
    AI_Messiah
    wrote on last edited by
    #1

    With C++ I could just use a thread that would call a method based on a measurement of time. QML itself as far as I know does not have something like this. The Timer object will speed up and slow down at a rate that does not look good. Finding what time it is I do not have a problem with.

    SeeLookS 1 Reply Last reply
    0
    • A AI_Messiah

      With C++ I could just use a thread that would call a method based on a measurement of time. QML itself as far as I know does not have something like this. The Timer object will speed up and slow down at a rate that does not look good. Finding what time it is I do not have a problem with.

      SeeLookS Offline
      SeeLookS Offline
      SeeLook
      wrote on last edited by
      #2

      @AI_Messiah You might try to normalize every timer shoot by calculating elapsed time exactly:

      Timer {
          id: timer
          property real elap: 0
          property real lag: 0
          property int exactInterval: 100
          running: true
          repeat: true
          interval: exactInterval
          onRunningChanged: {
            if (running) { // reset
              elap = 0; lag = 0
            }
          }
          onTriggered: {
            var currTime = new Date().getTime()
            if (elap > 0) { // skip first shoot
              elap = currTime - elap
              lag += elap - interval
            }
            elap = currTime
            interval = exactInterval - lag
            lag = 0
          }
        }
      
      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