当前位置:   article > 正文

qml一个程序里多个loops动画对另一个程序qml显示的刷新的影响_loops qml

loops qml
  1. property int rpm: 1000
  2.     property real rpmAngleTo: 270 / 10000 * rpm
  3.     property int speed: 150
  4.     property real speedAngleTo: 270 / 200 * speed
  5. transitions: [
  6. Transition {
  7. from: ""
  8. to: "show"
  9. ParallelAnimation{
  10. NumberAnimation { target: dashboardPanel; property: "opacity"; to: 1.0; duration: 100; }
  11. SequentialAnimation{
  12. NumberAnimation { target: dashboardPanel; property: "speed"; to: 200; duration: 800; }
  13. NumberAnimation { target: dashboardPanel; property: "speed"; to: 0; duration: 800; }
  14. NumberAnimation { target: dashboardPanel; property: "speed"; to: 100; duration: 500; }
  15. NumberAnimation { target: dashboardPanel; property: "speed"; to: 80; duration: 1000; }
  16. NumberAnimation { target: dashboardPanel; property: "speed"; to: 90; duration: 1000; }
  17. NumberAnimation { target: dashboardPanel; property: "speed"; to: 100; duration: 1000; }
  18. NumberAnimation { target: dashboardPanel; property: "speed"; to: 118; duration: 1000; }
  19. SequentialAnimation{
  20. loops: Animation.Infinite
  21. NumberAnimation { target: dashboardPanel; property: "speed"; from: 118;to: 120; duration: 1000; }
  22. NumberAnimation { target: dashboardPanel; property: "speed"; to: 110; duration: 1000; }
  23. NumberAnimation { target: dashboardPanel; property: "speed"; to: 115; duration: 1000; }
  24. NumberAnimation { target: dashboardPanel; property: "speed"; to: 118; duration: 1000; }
  25. NumberAnimation { target: dashboardPanel; property: "speed"; to: 110; duration: 1000; }
  26. NumberAnimation { target: dashboardPanel; property: "speed"; to: 115; duration: 1000; }
  27. NumberAnimation { target: dashboardPanel; property: "speed"; to: 118; duration: 1000; }
  28. }
  29. }
  30. SequentialAnimation{
  31. NumberAnimation { target: dashboardPanel; property: "rpm"; to: 8000; duration: 600; }
  32. NumberAnimation { target: dashboardPanel; property: "rpm"; to: /*12*/0; duration: 600; }
  33. NumberAnimation { target: dashboardPanel; property: "rpm"; to: 3000; duration: 700; }
  34. NumberAnimation { target: dashboardPanel; property: "rpm"; to: 4000; duration: 800; }
  35. NumberAnimation { target: dashboardPanel; property: "rpm"; to: 5000; duration: 1000; }
  36. SequentialAnimation{
  37. loops: Animation.Infinite
  38. NumberAnimation { target: dashboardPanel; property: "rpm"; from:5000;to: 4500; duration: 1000; }
  39. NumberAnimation { target: dashboardPanel; property: "rpm"; to: 4800; duration: 1000; }
  40. NumberAnimation { target: dashboardPanel; property: "rpm"; to: 5000; duration: 1000; }
  41. NumberAnimation { target: dashboardPanel; property: "rpm"; to: 4600; duration: 1000; }
  42. NumberAnimation { target: dashboardPanel; property: "rpm"; to: 4300; duration: 1000; }
  43. NumberAnimation { target: dashboardPanel; property: "rpm"; to: 4600; duration: 1000; }
  44. NumberAnimation { target: dashboardPanel; property: "rpm"; to: 5000; duration: 1000; }
  45. }
  46. }
  47. }
  48. },
  49. Transition {
  50. from: "show"
  51. to: ""
  52. SequentialAnimation{
  53. NumberAnimation { target: dashboardPanel; property: "opacity"; to: 0.0; duration: 100; }
  54. ScriptAction{
  55. script: {
  56. dashboardPanel.state = "show"
  57. }
  58. }
  59. }
  60. }
  61. ]
  62. 另一个程序,检测网络发来了数据,通过emit nameChanged(),通知qml变量发生变化,刷新显示,虽然qml打印出来的数据发生了变化,
  63. 但是显示未变化,只是一开始变化,一两次。这种原因就是因为上面的程序同一个动画里出现了两次loops无限循环,其中一个rpm动画是几百几百的变化,
  64. 如果变化from ,to的值都去掉一个0,变化几十几十的变化,就不影响显示,单独让rpm变化,显示动一两次,然后就不变了,但是收到的数据还是变化的,
  65. 这种原因可能是太耗资源导致的,导致太耗资源的真正原因是rpm定义成了real 类型的,如果改成int 类型就不会有这种出乎意料的现象出现。
  66. Text {
  67.         id: speed
  68.         anchors.right: km_h.left
  69.         anchors.rightMargin: 5
  70.         y:15
  71. //        font.family:FontName.fontCurrentMicroSoftYahei
  72.         font.pixelSize: 40
  73.         opacity: 1.0
  74.         color: "#69d0ff"
  75.         text:{
  76.             console.log("speed"+carStatus.speed)
  77.            return carStatus.speed
  78.         }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/81444
推荐阅读
相关标签
  

闽ICP备14008679号