我有一個Column
三個元素,如果用戶點擊空格鍵,其中一個元素可以更改其可見性。爲了使可見性改變一下我順利可以添加move
過渡:父母的中心位置的y位置動畫
ApplicationWindow {
title: qsTr("Hello World")
width: 640
height: 480
visible: true
Column {
spacing: 2
Rectangle { color: "red"; width: 50; height: 50 }
Rectangle { id: greenRect; color: "green"; width: 20; height: 50 }
Rectangle { color: "blue"; width: 50; height: 20 }
move: Transition {
NumberAnimation { properties: "x,y"; duration: 1000 }
}
focus: true
Keys.onSpacePressed: greenRect.visible = !greenRect.visible
}
}
這工作。但是,如果我將Column
置於其母公司中,則可見性更改也會導致Column
的新的height
,因此也會導致新的y
的位置。
現在我不想Column
'跳'到新的位置,但也順利移動。因此,我已將此添加到Column
:
anchors.centerIn: parent
Behavior on y {
NumberAnimation { duration: 1000 }
}
但y
位置變化仍然沒有動畫。如何實現這一目標?