# Get parent UserWidget of Widget

**URL:** <https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221>\
**Category:** UI\
**Tags:** unreal-engine, Widget, question, Blueprint, UMG\
**Created:** [December 21, 2020, 11:47am UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221 "2020-12-21T11:47:56Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![GradessGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gradessgames/32/879067_2.png) [@GradessGames](https://forums.unrealengine.com/u/GradessGames)\
**Post date:** [December 21, 2020, 11:47am UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/1 "2020-12-21T11:47:56Z")

</div>

Hello!

Is there any way to get UserWidget object that is parent for Widget (like a button, text block, etc.)

![325305-изображение-2020-12-21-144640.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/a/5/7a56796509dab9d231ac603a826a2936d3f62830.png)

![325304-изображение-2020-12-21-144556.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/2/8/9286a7e175da90568d071a76e4950583aaeb2d4f.png)

Get parent returns Widget element, but not UserWidget object

![325306-изображение-2020-12-21-144906.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/8/f/38f58571d9f0853aac28ffbed96d017bd4de2bc7.png)

---

<div class="post-metadata">

**Author:** ![Fraps2020](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fraps2020/32/460865_2.png) [@Fraps2020](https://forums.unrealengine.com/u/Fraps2020)\
**Post date:** [December 21, 2020, 2:18pm UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/2 "2020-12-21T14:18:33Z")

</div>

I’m not sure I understand your question, but if you’re getting a widget as a return of GetParent it might mean your button is parented to a widget that in turn is part of your userwidget. In that case what you need to do is to call GetParent again on the output of your first GetParent; or anyway repeat this if you have nested widgets until you get to your userwidget

---

<div class="post-metadata">

**Author:** ![GradessGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gradessgames/32/879067_2.png) [@GradessGames](https://forums.unrealengine.com/u/GradessGames)\
**Post date:** [December 21, 2020, 6:36pm UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/3 "2020-12-21T18:36:03Z")

</div>

No, it doesn’t work ☹

I call GetParent() on CanvasPanel and it always returns null

![325350-изображение-2020-12-21-213454.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/8/6/e86fd7c26fe7534f9b860363456cc4f68da5dd46.png)

---

<div class="post-metadata">

**Author:** ![Firefly74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Firefly74](https://forums.unrealengine.com/u/Firefly74)\
**Post date:** [September 23, 2021, 1:03pm UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/4 "2021-09-23T13:03:15Z")

</div>

Hey,  
i was looking for this and i found the answer, you need to use the “outer object”

in my cas i was calling it in an child user widget

```
container userwidget ( i want to get this )
    overlay
        canvas 
            child userwidget ( i'm calling from here )

```

 ![349231-userwidget.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/8/8/988a8291d149b61d1f3ef49f32a4b7175e8639eb.jpeg)

---

<div class="post-metadata">

**Author:** ![SithHunter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SithHunter](https://forums.unrealengine.com/u/SithHunter)\
**Post date:** [September 23, 2021, 2:57pm UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/5 "2021-09-23T14:57:06Z")

</div>

The method I use is to add a variable into the widget that is going to be the child of the class of the intended parent and expose it on spawn, then when you create the widget you can just add a reference to self to the input for that variable.

---

<div class="post-metadata">

**Author:** ![Paulo\_Egidio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Paulo\_Egidio](https://forums.unrealengine.com/u/Paulo_Egidio)\
**Post date:** [October 30, 2021, 2:05pm UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/6 "2021-10-30T14:05:05Z")

</div>

unless you do fancy stuff with outer object allocation, this should return the first parent canvas

best regards  
Paulo Egidio  
Multiverse Designer

```
UCanvasPanel* GetParentCanvas(UWidget* widget)
{
	UCanvasPanel* Canvas = nullptr;
	do
	{
	startloop:
		auto candidate = widget->GetParent();
		if (candidate == nullptr)
		{
			// try outer object
			UObject* outter = widget;
			while (true)
			{
				outter = outter->GetOuter();
				if (outter == nullptr)
					return nullptr;
				auto w = Cast<UWidget>(outter);
				if (w != nullptr)
				{
					widget = w;
					goto startloop;
				}
			}
		}
		else
			widget = candidate;
		Canvas = Cast<UCanvasPanel>(widget);
	} while (Canvas == nullptr);
	return Canvas;
}
```

---

<div class="post-metadata">

**Author:** ![Virtuality](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/virtuality/32/1140891_2.png) [@Virtuality](https://forums.unrealengine.com/u/Virtuality)\
**Post date:** [May 19, 2023, 8:25am UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/7 "2023-05-19T08:25:34Z")

</div>

Excellent, this helped me a lot today: `Parent->Outer->Outer->Cast` works great. It seems that just` Outer->Outer->Cast` works as well, since the result from the first Outer is always the tree structure.

---

<div class="post-metadata">

**Author:** ![Bozzified](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bozzified](https://forums.unrealengine.com/u/Bozzified)\
**Post date:** [January 18, 2025, 9:23am UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/8 "2025-01-18T09:23:38Z")

</div>

I’m working on some UI now and just wanted to chime in since I stumbled upon this post.

Just a tip here. You don’t have to go through hierarchy like that. It becomes inefficient if you have a lot of elements.

Just use CommonUI Find Parent Widget of Type node if you are looking for an actual parent widget class of the sub widget and not the container element/s.

---

<div class="post-metadata">

**Author:** ![Javad\_Rezaii](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/javad_rezaii/32/948244_2.png) [@Javad\_Rezaii](https://forums.unrealengine.com/u/Javad_Rezaii)\
**Post date:** [January 31, 2025, 12:23pm UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/9 "2025-01-31T12:23:18Z")

</div>

I have used 4 Get Outer Objects to reach my parent widget 😃

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/9/62931d7d15714ba28e88db55d8d81bdb9eb44deb.png)

---

<div class="post-metadata">

**Author:** ![AllGamesSuck](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AllGamesSuck](https://forums.unrealengine.com/u/AllGamesSuck)\
**Post date:** [May 27, 2025, 10:39am UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/10 "2025-05-27T10:39:35Z")

</div>

> [@Bozzified](#):
>
> Just use CommonUI Find Parent Widget of Type node if you are looking for an actual parent widget class of the sub widget and not the container element/s.

Hi, how do you do that in blueprints?

---

<div class="post-metadata">

**Author:** ![Kemichar](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kemichar/32/1069671_2.png) [@Kemichar](https://forums.unrealengine.com/u/Kemichar)\
**Post date:** [May 27, 2025, 12:38pm UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/11 "2025-05-27T12:38:52Z")

</div>

> [@AllGamesSuck](#):
>
> Hi, how do you do that in blueprints?

Just use the function Bozzified mentioned, it’s exposed to BP.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/7/5/87516b3b5488979aa93ccdd347a8e9ac61926088.png)

---

<div class="post-metadata">

**Author:** ![AllGamesSuck](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AllGamesSuck](https://forums.unrealengine.com/u/AllGamesSuck)\
**Post date:** [May 27, 2025, 1:55pm UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/12 "2025-05-27T13:55:32Z")

</div>

Can’t find that function.

---

<div class="post-metadata">

**Author:** ![Kemichar](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kemichar/32/1069671_2.png) [@Kemichar](https://forums.unrealengine.com/u/Kemichar)\
**Post date:** [May 27, 2025, 2:12pm UTC](https://forums.unrealengine.com/t/get-parent-userwidget-of-widget/476221/13 "2025-05-27T14:12:48Z")

</div>

Ah, forgot to mention that you need the CommonUI plugin enabled for this to be available. It’s a decent plugin if you’re not using C++ because it comes with extra widgets and functionalities you otherwise wouldn’t get without C++; if you’re using C++ and you don’t want CommonUI, just add the function yourself in your own function library.
