Changing properties of multiple targets per state
-
Hello,
I have a simple problem but i cant seem to find a solution. For letting the user chose one of multiple items, i wanted somthing like a wheel with the middle item beeing the chosen item. You might now similar or identical designs from your cell phone when you set your alarm to a certain time.
I thought the easiest way would be to set three rectangles as placeholders and define states with transitions to make the images move from rectangle to rectangle. Here is an extract from the code:Image {id: image1; ....} Image {id: image2; ....} Image {id: image3; ....} Rectangle{id: leftrec; anchors.left: parent.left: ....} Rectangle{id: middlerec; anchors.centerIn: parent: ....} Rectangle{id: rightrec; anchors.right: parent.right: ....} StateGroup{ id: stategroup states: [ State { name: "State1" PropertyChanges {target: image1; x: leftrec.x; .....} PropertyChanges {target: image2; x: middlerec.x; ....} PropertyChanges {target: image3; x: rightrec.x; ....} }, State{ name: "State2" PropertyChanges {target: image3; x: leftrec.x; .....} PropertyChanges {target: image1; x: middlerec.x; ....} PropertyChanges {target: image2; x: rightrec.x; ....} }, State{ name: "State3" PropertyChanges {target: image2; x: leftrec.x; .....} PropertyChanges {target: image3; x: middlerec.x; ....} PropertyChanges {target: image1; x: rightrec.x; ....} } ] transitions: [ Transition { from: "State1"; to: "State2" NumberAnimation {properties: "x,y,width,height"; duration: 1000} }, // and so on... I think you get the drill
When I execute the code the following happens:
Only the properties of the first target are changing. But for some reason the properties of the second target are applied to my first target. I dont really understand why this is happening, I checked all the IDs and they seem to be ok.PS: Please dont worry that my transition form rightrec to leftrec will look like shit, in the actual code I took care of that problem.
-
You have anchored and using x value as well. When you use the anchors, setting x values will not work. Remove your anchor settings. Everything should work fine.
-
Damn you are right. But the anchors are only on the Rectangle, which dont move anyway. Why do the anchors on the fixed rectangles matter?
-
Anchors always have precedence over x and y. Does not matter which items