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

property int rpm: 1000
    property real rpmAngleTo: 270 / 10000 * rpm
    property int speed: 150
    property real speedAngleTo: 270 / 200 * speed

transitions: [
        Transition {
            from: ""
            to: "show"
            ParallelAnimation{
                NumberAnimation { target: dashboardPanel; property: "opacity"; to: 1.0; duration: 100; }
                SequentialAnimation{
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 200; duration: 800; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 0; duration: 800; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 100; duration: 500; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 80; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 90; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 100; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 118; duration: 1000; }

                    SequentialAnimation{
                        loops: Animation.Infinite
                    NumberAnimation { target: dashboardPanel; property: "speed"; from: 118;to: 120; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 110; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 115; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 118; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 110; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 115; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "speed"; to: 118; duration: 1000; }
                    
                }
                }
                SequentialAnimation{
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: 8000; duration: 600; }
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: /*12*/0; duration: 600; }
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: 3000; duration: 700; }
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: 4000; duration: 800; }
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: 5000; duration: 1000; }
                    SequentialAnimation{
                        loops: Animation.Infinite
                    NumberAnimation { target: dashboardPanel; property: "rpm"; from:5000;to: 4500; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: 4800; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: 5000; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: 4600; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: 4300; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: 4600; duration: 1000; }
                    NumberAnimation { target: dashboardPanel; property: "rpm"; to: 5000; duration: 1000; }
                }
                }
            }
        },
        Transition {
            from: "show"
            to: ""
            SequentialAnimation{

                NumberAnimation { target: dashboardPanel; property: "opacity"; to: 0.0; duration: 100; }
                ScriptAction{
                    script: {
                        dashboardPanel.state = "show"
                    }
                }
            }
        }
    ]



另一个程序,检测网络发来了数据,通过emit nameChanged(),通知qml变量发生变化,刷新显示,虽然qml打印出来的数据发生了变化,
但是显示未变化,只是一开始变化,一两次。这种原因就是因为上面的程序同一个动画里出现了两次loops无限循环,其中一个rpm动画是几百几百的变化,
如果变化from ,to的值都去掉一个0,变化几十几十的变化,就不影响显示,单独让rpm变化,显示动一两次,然后就不变了,但是收到的数据还是变化的,
这种原因可能是太耗资源导致的,导致太耗资源的真正原因是rpm定义成了real 类型的,如果改成int 类型就不会有这种出乎意料的现象出现。

 Text {
        id: speed
        anchors.right: km_h.left
        anchors.rightMargin: 5
        y:15
//        font.family:FontName.fontCurrentMicroSoftYahei
        font.pixelSize: 40
        opacity: 1.0
        color: "#69d0ff"
        text:{
            console.log("speed"+carStatus.speed)
           return carStatus.speed
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值