[Qt-qml] Change property of dynamically created component

warwick.allison at nokia.com warwick.allison at nokia.com
Wed Nov 10 01:54:38 CET 2010


The id of a component does not become a new global identifier. i.e. "yellowRect" below:

    Component {
        id: yellowRectComponent
        Rectangle {
            id: yellowRect
            width: 100
            height: 100
            color: "yellow"
        }
    }

As you can imagine: if you had 2 loaders that loaded this, what would happen?

So, to fix your example, instead of:

            PropertyChanges {
                target: yellowRect
                color: "gray"
            }

You need:

            PropertyChanges {
                target: loader.item
                color: "gray"
            }

--
Warwick




More information about the Qt-qml mailing list