[Interest] QtQuick: how to connect the signal of an object that was created dynamically?

hualet mr.asianwang at gmail.com
Sat Nov 29 15:53:09 CET 2014


oh, didn’t even think about this method before, thanks Godbout :)
> 在 2014年11月28日,下午9:44,Jérôme Godbout <jerome at bodycad.com> 写道:
> 
> You can connect it directly to an handler or another signal:
> 
> Component
> {
>    id: myComponent
>    Item
>    {
>       signal toto()
>    }
> }
> 
> function myCreateFct()
> {
>   // create the object
>   var myNewObj = myComponent.createObject(wantedParent, {});
>   myNewObj.toto.connect(myHandlerDynamicObj);
> }
> 
> function myHandlerDynamicObj()
> {
>   // handle signal here...
> }
> 
> If you want to have the object into parameters you can use a lambda into the handler
> 
> myNewObj.toto.connect(myHandlerDynamicObj); --> 
> myNewObj.toto.connect(function() { myHandlerDynamicObj(myNewObj); });
> 
> function myHandlerDynamicObj(myObj) {}
> 
> You can also use the disconnect the same way
> 
> On Fri, Nov 28, 2014 at 12:22 AM, hualet <mr.asianwang at gmail.com <mailto:mr.asianwang at gmail.com>> wrote:
> Hi, dear list, like what I said in the title, is there a way to connect the signal of an object that was created dynamically? thanks ;)
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org <mailto:Interest at qt-project.org>
> http://lists.qt-project.org/mailman/listinfo/interest <http://lists.qt-project.org/mailman/listinfo/interest>
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141129/4b67d12c/attachment.html>


More information about the Interest mailing list