FpsItem.qml 844 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import QtQuick 2.0
  2. Item {
  3. id: root
  4. property int frameCounter: 0
  5. property int fps: 0;
  6. width: 160
  7. height: 48
  8. Image {
  9. id: spinnerImage
  10. source: "images/spinner.png"
  11. NumberAnimation on rotation {
  12. from:0
  13. to: 360
  14. duration: 800
  15. loops: Animation.Infinite
  16. }
  17. onRotationChanged: frameCounter++;
  18. }
  19. Text {
  20. anchors.right: parent.right
  21. anchors.verticalCenter: spinnerImage.verticalCenter
  22. color: "#ffffff"
  23. style: Text.Outline
  24. styleColor: "#606060"
  25. font.pixelSize: 28
  26. text: root.fps + " fps"
  27. }
  28. Timer {
  29. interval: 2000
  30. repeat: true
  31. running: true
  32. onTriggered: {
  33. fps = frameCounter/2;
  34. frameCounter = 0;
  35. }
  36. }
  37. }