Hi Thomas,

2010/12/8 Thomas PABST <thomas.pa...@gmail.com>:
> When we design new QML Element which can be call by a lot of other QML
> elements( Items, Buttons ...) we sometime need to know which call it.
> I am looking for a way to know how the current element was called. Which is
> the source, but only with qml or JavaScript, not c++.
> On my case, many elements call only one element. But the action will differ
> depending on who called it.

Do you mean "can be a child" or do you mean "can be called"? What is
an action in that case then? Can you give an example?

If it's about child elements, maybe you can solve the problem by
properties on the child element, so that the properties control how it
looks/what it does (this also makes it more modular, as the child does
not need to know the details about its surroundings, but rather only
needs to know its properties and what they mean).

If it's about some callback/function, the same thing applies - just
pass the action you want to do as parameter (e.g. an enum or a string
describing the action), so that the callee does not need to know who
called and from where - improves modularity, and should produce
cleaner code.

HTH.
Thomas
_______________________________________________
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to