>
> Ah, but I believe you’re missing the bigger picture.

Honestly referencing UI this way seems to promote not using an established
pattern.  For debugging purposes it may be useful, but for production code
referencing UI elements like this should most likely be avoided.

What ends up happening is that whenever you introduce another widget
> in-between two widget, you’ll have to pick up those signals and forward
> them to the next, and so the story goes. Changing anything was a nightmare.
> To borrow terminology from Chad, it’s quite the PITA.


Perhaps there is another issue with the overall design if it's ending up
becoming a tangled mess.  Are you using QAbstractItemModels or the Qt "MVC"
framework?  Once I understood how to use or extend their built in classes
my life became a lot simpler.

With qtpath, my thinking is that logical hierarchies can be decoupled from
> their physical hierarchy, in that widgets with no objectName are skipped
> during traversal. That way, programmers can design a hierarchy they wish to
> program against, regardless of any hierarchy Qt enforces upon you (e.g.
> QScrollArea having multiple unexpected children).


Using an established MVC design principle should allow you to design your
hierarchies as you see fit and avoid this problem...I hate pulling out
lingo like MVC but trying to use an established pattern can really help you
design more modular/flexible code.

This is just from my experience so take it with a grain of salt.  I've
typically found if everything starts to become a tangled mess or it's
getting hard to maintain I'm doing it wrong.



On Tue, Jun 3, 2014 at 5:35 PM, Marcus Ottosson <[email protected]>
wrote:

> Ah, but I believe you’re missing the bigger picture.
>
> Files and folders have absolute paths and we can reference them. But of
> course, coding anything to absolute paths is no good and I believe the same
> is true for object hierarchies. With files, we develop resolvers and
> expression to help decouple them from their roots; I believe the same could
> be true for object hierarchies.
>
> The problem with directly referencing anything is the spaghetti of links
> you get between objects operating on other objects.
>
> The need arose when working with many widgets composited within other
> widgets (think ItemViews) and where each item needed to signal an event up
> through a hierarchy. To keep everything perfectly decoupled, it made sense
> to not introduce a global variable or singleton and have each level instead
> receive a signal and forward it to its parent until eventually being
> handled by the topmost parent. Simple in theory.
>
> In theory, theory and practice are the same. In practice, they are not. -
> Albert Einstein
>
> What ends up happening is that whenever you introduce another widget
> in-between two widget, you’ll have to pick up those signals and forward
> them to the next, and so the story goes. Changing anything was a nightmare.
> To borrow terminology from Chad, it’s quite the PITA.
>
> With qtpath, my thinking is that logical hierarchies can be decoupled
> from their physical hierarchy, in that widgets with no objectName are
> skipped during traversal. That way, programmers can design a hierarchy they
> wish to program against, regardless of any hierarchy Qt enforces upon you
> (e.g. QScrollArea having multiple unexpected children).
>
> # Reference `button`, even though there may be multiple levels of unnamed 
> parents inbetween.
> $ /root.QWidget/button.QPushButton
>
> As for your example, of two object names being identical, this is
> something I would consider poor programming effort and I’d entrust
> programmers to not get themselves in such a situation.
>
> Thoughts?
> ​
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCWBbt%3DRNz2TMiehsHJCtWoSnF2zU7OCsYGpt3qXdCQDg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCWBbt%3DRNz2TMiehsHJCtWoSnF2zU7OCsYGpt3qXdCQDg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-tony

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAJhmvsTyzdpqUUEfs3Xjoc_wF-Kd8D6%2BT%2BKHs2T%3D7NNjJj%2BNzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to