FPSMonitor.qml 799 B

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