This code doesn't make much sense, if you ask me. I can't even get it to work.
If you want to fade two images using states then this works:
import QtQuick 2.4
Item {
anchors.fill: parent
states: [
State { // this will fade in rect2 and fade out rect
name: "fadeInRect2"
PropertyChanges { target: rect; opacity: 0}
PropertyChanges { target: rect2; opacity: 1}
},
State { // this will fade in rect and fade out rect2
name:"fadeOutRect2"
PropertyChanges { target: rect;opacity:1}
PropertyChanges { target: rect2;opacity:0}
}
]
transitions: [
Transition {
NumberAnimation { property: "opacity"; easing.type: Easing.InOutQuad; duration: 2500 }
}
]
Image {
id: rect2
smooth: true
anchors.fill: parent
source: "/usr/share/icons/oxygen/256x256/apps/yakuake.png"
}
Image {
id: rect
smooth: true
anchors.fill: parent
source: "/usr/share/icons/oxygen/256x256/apps/showfoto.png"
}
state: "fadeInRect2"
MouseArea {
anchors.fill: parent
onClicked: {
parent.state = parent.state == "fadeInRect2" ? "fadeOutRect2" : "fadeInRect2"
}
}
}
import QtQuick 2.4
Item {
anchors.fill: parent
states: [
State { // this will fade in rect2 and fade out rect
name: "fadeInRect2"
PropertyChanges { target: rect; opacity: 0}
PropertyChanges { target: rect2; opacity: 1}
},
State { // this will fade in rect and fade out rect2
name:"fadeOutRect2"
PropertyChanges { target: rect;opacity:1}
PropertyChanges { target: rect2;opacity:0}
}
]
transitions: [
Transition {
NumberAnimation { property: "opacity"; easing.type: Easing.InOutQuad; duration: 2500 }
}
]
Image {
id: rect2
smooth: true
anchors.fill: parent
source: "/usr/share/icons/oxygen/256x256/apps/yakuake.png"
}
Image {
id: rect
smooth: true
anchors.fill: parent
source: "/usr/share/icons/oxygen/256x256/apps/showfoto.png"
}
state: "fadeInRect2"
MouseArea {
anchors.fill: parent
onClicked: {
parent.state = parent.state == "fadeInRect2" ? "fadeOutRect2" : "fadeInRect2"
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks