6
社区成员




Timer {
id: timer2
interval:1000 // 每隔1秒触发一次
running: true // 启动定时器
repeat: true //重复触发
onTriggered: {
var animation = PropertyAnimation {
target: rect
property: ["x", "y"]
to: Qt.point(Math.random() * (parent.width - rect.width), Math.random() * (parent.height - rect.height))
duration:1000 // 动画持续时间为1秒
easing.type: Easing.InOutQuad // 缓动函数为InOutQuad
}
animation.start() // 启动属性动画
}
}
这段QML代码有什么问题吗?需要怎么修改呢?