[Qt-qml] Reacting on signals emitted by an Item loaded by a Loader
Cornelius Hald
hald at icandy.de
Sat Sep 4 11:52:11 CEST 2010
On Fri, 2010-09-03 at 15:31 -0300, Adriano Rezende wrote:
> 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)
> }
> }
Adriano, thanks a lot. That did the trick :)
Cheers,
Conny
More information about the Qt-qml
mailing list