QML列平滑数据信息未按预期工作

QML列平滑数据信息未按预期工作,qml,Qml,当我在计时器中更改cluster_Odo_0.位置时,我能够使数字从bootom滚动到top。 但当交易进行到9时,我可以看到所有的数字从9到零。。如何从9突然变为0,使中间数字不可见 如何使信息顺畅工作 main.xml:--- GuageNumbers.qml文件:--- 导入QtQuick 2.0 Item { id: container //anchors.centerIn: parent width: 20 height: 20 clip: tr

当我在计时器中更改cluster_Odo_0.位置时,我能够使数字从bootom滚动到top。 但当交易进行到9时,我可以看到所有的数字从9到零。。如何从9突然变为0,使中间数字不可见

如何使信息顺畅工作

main.xml:---

GuageNumbers.qml文件:--- 导入QtQuick 2.0

Item {
    id: container
    //anchors.centerIn: parent
    width: 20
    height: 20
    clip: true
    property int position: 0
    Column {
        id: image
        y: -container.position * 20
        Repeater {
            model: 10
            delegate: Rectangle {
                width: 20
                height: 20
                color: "#00000000"
                Text {
                    anchors.fill: parent
                    verticalAlignment: Text.AlignVCenter
                    horizontalAlignment: Text.AlignHCenter
                    text: index
                    font.pixelSize: 16
                    color: "orange"
                }
            }

        }

        Behavior on x { SmoothedAnimation { velocity: 50;duration: 500; loops: Animation.Infinite; } }
                Behavior on y { SmoothedAnimation { velocity: 50;duration: 600; loops: Animation.Infinite; } }
        focus: true

        //spacing: 1
    }
}

另一个解决方案是将频带移动到初始位置,持续时间为0,我认为代码可以更好地描述这一点:

导入QtQuick 2.12
导入QtQuick.Window 2.12
窗口{
可见:正确
宽度:400
身高:300
长方形{
宽度:42
身高:52
anchors.centerIn:父对象
边框{宽度:1;颜色:#999}
长方形{
宽度:40
身高:50
anchors.centerIn:父对象
剪辑:对
梯度:梯度{
渐变停止{位置:0.0;颜色:“白色”}
渐变停止{位置:0.5;颜色:“浅灰色”}
渐变停止{位置:1.0;颜色:“白色”}
}
纵队{
id:集装箱
属性int位置:0
y:-位置*50
x:0
中继器{
型号:11
代表:文本{
文本:索引%10
宽度:40
身高:50
垂直对齐:Text.AlignVCenter
水平对齐:Text.AlignHCenter
font.pixelSize:24
颜色:“橙色”
}
}
在y上的行为{
顺序动画{
数字化{
id:bouncebehavior
持续时间:900
缓和{
类型:中国内地
振幅:10.0
期间:1.5
}
}
脚本动作{
脚本:container.goBack();
}
}
}
函数goBack()
{
如果(container.pos==10)
{
bouncebehavior.duration=0;
container.pos=0;
bouncebehavior.duration=900;
}
}
}
}
计时器{
间隔时间:1000
重复:对
跑步:对
反对:{
container.pos++
}
}
}
}

另一种解决方案是将波段移动到初始位置,持续时间为:0,我认为代码可以更好地描述这一点:

导入QtQuick 2.12
导入QtQuick.Window 2.12
窗口{
可见:正确
宽度:400
身高:300
长方形{
宽度:42
身高:52
anchors.centerIn:父对象
边框{宽度:1;颜色:#999}
长方形{
宽度:40
身高:50
anchors.centerIn:父对象
剪辑:对
梯度:梯度{
渐变停止{位置:0.0;颜色:“白色”}
渐变停止{位置:0.5;颜色:“浅灰色”}
渐变停止{位置:1.0;颜色:“白色”}
}
纵队{
id:集装箱
属性int位置:0
y:-位置*50
x:0
中继器{
型号:11
代表:文本{
文本:索引%10
宽度:40
身高:50
垂直对齐:Text.AlignVCenter
水平对齐:Text.AlignHCenter
font.pixelSize:24
颜色:“橙色”
}
}
在y上的行为{
顺序动画{
数字化{
id:bouncebehavior
持续时间:900
缓和{
类型:中国内地
振幅:10.0
期间:1.5
}
}
脚本动作{
脚本:container.goBack();
}
}
}
函数goBack()
{
如果(container.pos==10)
{
bouncebehavior.duration=0;
container.pos=0;
bouncebehavior.duration=900;
}
}
}
}
计时器{
间隔时间:1000
重复:对
跑步:对
反对:{
container.pos++
}
}
}
}

我将使用。有时我回答了类似的问题,我记得还提供了代码示例,但不幸的是,我找不到:(将检查此..谢谢,我将使用)。有时我回答了类似的问题,我记得还提供了代码示例,但不幸的是,我找不到:(将对此进行检查..谢谢您建议使用pathanimation还是过程..?哪一个是最好的?您建议使用pathanimation还是过程..?哪一个是最好的?
Item {
    id: container
    //anchors.centerIn: parent
    width: 20
    height: 20
    clip: true
    property int position: 0
    Column {
        id: image
        y: -container.position * 20
        Repeater {
            model: 10
            delegate: Rectangle {
                width: 20
                height: 20
                color: "#00000000"
                Text {
                    anchors.fill: parent
                    verticalAlignment: Text.AlignVCenter
                    horizontalAlignment: Text.AlignHCenter
                    text: index
                    font.pixelSize: 16
                    color: "orange"
                }
            }

        }

        Behavior on x { SmoothedAnimation { velocity: 50;duration: 500; loops: Animation.Infinite; } }
                Behavior on y { SmoothedAnimation { velocity: 50;duration: 600; loops: Animation.Infinite; } }
        focus: true

        //spacing: 1
    }
}