[Qt-qml] Reacting on signals emitted by an Item loaded by a Loader

Adriano Rezende adriano.rezende at openbossa.org
Fri Sep 3 20:31:18 CEST 2010


On Fri, Sep 3, 2010 at 12:14 PM, Cornelius Hald <hald at icandy.de> wrote:
>
> And then in Item1.qml I did:
> MouseArea {
>  onClicked: container.parent.wasClicked()
> }
>
> That did work, but I think it that using signals is cleaner. So any
> pointers would be really appreciated.

You should use connections to capture signals from the loaded item.

You can do like below:

Item {
    width: 300
    height: 300

    MouseArea {
        anchors.fill: parent
        onClicked: loader.source = "Item.qml";
    }

    Loader {
        id: loader
    }

    Connections {
        target: loader.item
        onHello: console.log(message)
    }
}

Br,
Adriano




More information about the Qt-qml mailing list