有谁知道如何实现线性动画,例如进度栏中的动画,其中几乎没有线条在栏中从左向右移动或以其他方式无限移动?我将仅使用QtQuick2原语,并且不使用任何其他C ++组件,很高兴看到可以满足此要求的任何答案。另外,我知道如何为动画设置无限循环,但是实际的问题是如何在无限循环中将矩形/线的行从letf移到右侧,我无法想象实现这一点的方法。
最佳答案
这样的东西?
Rectangle {
width: 400
height: 30
anchors.centerIn: parent
border.color: "grey"
border.width: 1
clip: true
Rectangle {
id: runner
property double percent: 0.2
width: parent.width * percent
height: parent.height
color: "orange"
NumberAnimation on x { from: runner.width * (-1); to: 400; duration: 2000; loops: Animation.Infinite }
}
}