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

来源:互联网 发布:python 推荐系统 编辑:程序博客网 时间:2024/05/18 14:23
property int rpm: 1000    property real rpmAngleTo: 270 / 10000 * rpm    property int speed: 150    property real speedAngleTo: 270 / 200 * speedtransitions: [        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        }

0 0
原创粉丝点击