FPS.qml 803 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. height: fpsText.height
  8. width: fpsText.width
  9. Text {
  10. id: fpsText
  11. font.pixelSize: widgetProperties.fontPixelSize
  12. color: "white"
  13. text: "FPS:" + fpsTimer.fps
  14. }
  15. Timer {
  16. id: fpsTimer
  17. property real fps: 0
  18. repeat: true
  19. interval: 1000
  20. running: true
  21. onTriggered: {
  22. fps = frame
  23. frame = 0
  24. }
  25. }
  26. NumberAnimation on t {
  27. id: tAnim
  28. from: 0
  29. to: 100
  30. loops: Animation.Infinite
  31. }
  32. onTChanged: {
  33. update() // force continuous animation
  34. ++frame
  35. }
  36. }