【发布时间】:2017-11-10 14:22:09
【问题描述】:
我有以下 QML 文件。单击 root 项时,我不希望矩形 myRect 从右侧滑入(简化设置)。实际发生的是 myRect 在单击 root 项目时立即出现。
我检查了过渡的 running 属性,这似乎没问题。当我单击 root 项时,它会记录 true,然后在 2 秒后记录 false。
有谁知道为什么 x 属性不会逐渐改变?
import QtQuick 2.7
Item{
id: root
MouseArea{
anchors.fill: parent
onClicked: {
myRect.state = "visible"
}
}
Rectangle{
id: myRect
width: root.width
height: root.height
state: "hidden"
color: "yellow"
states: [
State {
name: "hidden"
PropertyChanges{
target: myRect
x: myRect.width
}
},
State {
name: "visible"
PropertyChanges{
target: myRect
x: 0
}
}
]
transitions: [
Transition {
NumberAnimation{
duration: 2000
}
onRunningChanged: {
console.log("Running:", running)
}
}
]
}
}
【问题讨论】:
标签: qt qml qtquick2 transitions