1
import QtQuick 2.0
Rectangle {
id: rec
property int img_in:2
property int img_out:3
Image {
id: imgout
source: "pics/"+img_out+".jpg"
opacity: 1
anchors.fill: parent
}
Image {
id: imgin
source: "pics/"+img_in+".jpg"
opacity: 0
anchors.fill: imgout
}
Timer {
interval: 5000
repeat: true
running: true
onTriggered: {
img_in = img_in+1
img_out = img_out+1
anim.running = true;
}
}
states: State {
name: "state1"
PropertyChanges { target: imgout; opacity: 0}
PropertyChanges { target: imgin; opacity: 1}
}
SequentialAnimation {
id: anim
NumberAnimation { target: imgin; properties: "opacity"; easing.type: Easing.InOutQuad; duration: 1500 }
NumberAnimation { target: imgout; properties: "opacity"; easing.type: Easing.InOutQuad; duration: 1500 }
}
合併,我想知道,如果問題是出在不透明或圖片數量的變化。圖片確實發生了變化(突然),但沒有動畫。 Inside onTriggered我試圖使用這些選項:狀態,SequentialAnimation加轉換。沒有幫助。
「rec'」狀態永遠不會改變,所以'opacity'屬性不會改變爲。當你做'anim.running = true'時,不透明度就沒有任何要求。 – Kirween
你能解釋一下你準備用imgin和imgout完成什麼嗎?例如,你想讓imgin淡入淡出,並在時間到期時淡出嗎? – Matthew