FPS.qml 630 B

1234567891011121314151617181920212223242526272829303132333435
  1. import QtQuick 2.0
  2. // pretty much entirely stolen from:
  3. // https://github.com/capisce/motionblur/blob/master/main.qml
  4. Widget {
  5. property real t
  6. property int frame: 0
  7. text: "FPS:" + fpsTimer.fps
  8. Timer {
  9. id: fpsTimer
  10. property real fps: 0
  11. repeat: true
  12. interval: 1000
  13. running: true
  14. onTriggered: {
  15. fps = frame
  16. frame = 0
  17. }
  18. }
  19. NumberAnimation on t {
  20. id: tAnim
  21. from: 0
  22. to: 100
  23. loops: Animation.Infinite
  24. }
  25. onTChanged: {
  26. update() // force continuous animation
  27. ++frame
  28. }
  29. }