I'm struggling to understand the QML state concept.

I have the following code:

```
import QtQuick 2.1
import QtQuick.Controls 1.0

Rectangle{
    id: myRectangle
    width: 500
    height: 120

    state: "init"

    Button {

        id: myBtn1
        text: "hello"
        anchors.right: parent.right
        anchors.rightMargin: 40
        anchors.verticalCenter: parent.verticalCenter
        onClicked: {
            console.log("trying to change state to myState "
            myRectangle.state = "customState"
        }
    }
    Button {
        id: myBtn2
        text: "bye"
        anchors.right: parent.right
        anchors.rightMargin: 40
        anchors.verticalCenter: parent.verticalCenter
        onClicked: {
            myCppObject.coolFunction()
        }
        visible: false
    }

    Connections {
        target: myCppObject
        onCoolSignal: {
            console.log("signal triggered")
            console.log("state before signal: " + myRectangle.state);

            myRectangle.state = "init";

            console.log("state after signal: " + myRectangle.state);
        }

    }

    states: [
            State {
                name: "init"
                PropertyChanges {
                    target: myBtn1
                    visible:true
                }
                PropertyChanges {
                    target: myBtn2
                    visible: false
                }
            },
            State {
                name: "customState"
                PropertyChanges {
                    target: myBtn1
                    visible: false
                }
                PropertyChanges {
                    target: myBtn2
                    visible: true
                }
            }
    ]
}

```

My intension is that on click on the "myBtn1" this button should disappear and "myBtn2" should show up. Therefore I use the states as described and it so far it work! The state changes and the button with the label "bye" is visible.

In the next step the click on the button "myBtn2" calls the function "coolFunction" of "myCppObject" which only purpose is to emit a signal called "coolSignal" - which also works!
 My problem is that I do get the expected output in the console which is like:

```
signal triggered
state before signal: customState
state after signal: init

```

but "myBtn1" stays hidden and "myBtn2" stays visible!!! So the state is not really changed!!!
Any ideas what I'm not understanding about states in QML?

btw: if I change `myBtn2.onClick` to `myRectangle.state = "init";` the state transition works!!! But I really need it to happen on a custom C++ signal!

Thanks for any kind of help in advance.

EDIT:
I forgot to say that I don't use the source code written on the top inside the main.qml. It's inside an extra QML File called MyElem.qml which used as delegate elem for a listview. This means while running there is more than one of MyElem loaded and all of them have the same id (myRectangle). Is this the reason why I don't see any visual changes?