How to get parent widget?

I have two widget blueprints - Container and Element. Container consists of several panels with Elements on them.
I’m trying to access Container instance from Element. GetParent returns the panel from Container, but if II try to get that panel’s parent I sadly get null.
So is there a proper way to access parent User Widgets?

I had touble too with that, so my solution was to add a variable reference in the child with the parent value, and set it when the child widget is added … I don’t know if it can help you, and I have only some childs, it may be memoryvorous if they are many …

1 Like

Yes, that works, thanks.
Another way I found to get communication working is to add a dispatcher to Element and bind an event to each instance in Container.
This is somewhat more flexible but just as much bulky.
It would’ve been much easier if there was an easy way to iterate through widget tree or to share a dispatcher between all instances of a widget…

It works well,thx

Maybe someone else will need it. The parent widget can be obtained using “self → getParent → GetOuterObject-> GetOuterObject”. You may need to use GetOuter several more times to get the desired widget.

4 Likes

Alo, This post is old but I made a macro that should do this. I’m sure it can be improved though.
In the case of the two ‘get outer objects’, the widget components outer object is the widget tree, so you gotta do it twice.

You made my day.

1 Like

So will this widget continue to check each time? Shouldn’t this check the outer objects one by one?

Using what was mentioned above I created a function that keeps cycling through parent objects until the desired ones are found hope this helps