[SOLVED]Can't change state because "can't find variable"
-
wrote on 7 Oct 2011, 08:39 last edited by
Hi,
Another problem that I have is when I try to change a state:
@
Rectangle {
width: 400
height: 500Component{ id: myComponent Item { id:myItem height: 50 states: State { name: "resizeMyItem"; PropertyChanges { target: myItem; height: 100} } }
MouseArea {
width: 79
height: 69
onClicked: {myItem.state = "resizeMyItem"}
}@No issues when building this code but when I run it and click the mouse area, it says "ReferenceError: Can't find variable: myItem"
I googled some state examples and comparing to them I can't see where the problem is?
-
wrote on 7 Oct 2011, 08:55 last edited by
I just saw that it might be case problem in your code.
Maybe you have to write:
@
MouseArea {
width: 79
height: 69
onClicked: {myItem.State = "resizeMyItem"}
}@The only difference is that the first letter of "State" is now capitalized.
-
wrote on 7 Oct 2011, 09:02 last edited by
check your braces, seems like your item out of scope for MouseArea
-
wrote on 7 Oct 2011, 09:58 last edited by
Changing the "state" to "State" didn't help but I managed to call the state from inside the braces of "myComponent" so it works now. Thanks to both from help.
1/4