# UserWidget added as Child: always wrong size

**URL:** <https://forums.unrealengine.com/t/userwidget-added-as-child-always-wrong-size/344962>\
**Category:** UI\
**Tags:** child, unreal-engine, Widget, question, UMG\
**Created:** [January 22, 2016, 4:58pm UTC](https://forums.unrealengine.com/t/userwidget-added-as-child-always-wrong-size/344962 "2016-01-22T16:58:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![djchase](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@djchase](https://forums.unrealengine.com/u/djchase)\
**Post date:** [January 22, 2016, 4:58pm UTC](https://forums.unrealengine.com/t/userwidget-added-as-child-always-wrong-size/344962/1 "2016-01-22T16:58:01Z")

</div>

Hi,

I have programmed a minimap-widget which is derived from UUserWidget.

All actors in the world should be represented on the minimap by an own derived actor-UserWidget, which changes its behavior itself.

For example, if the related actor is dead, the actor-widget itself should become invisible.

So I have a minimap-widget with child-actor-widgets.

However, if I add the actor-widgets to the minimap-widget with UPanelWidget::AddChild, the widgets always have a wrong size.

It should be 100_100, but it looks like 200_50.

Is this a bug ?

In the UMG-designer I can add my custom actor widget to the minimap widget, and it looks correct.

Can you help ? Any clues ?

Thanks!

---

<div class="post-metadata">

**Author:** ![Heroico](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Heroico](https://forums.unrealengine.com/u/Heroico)\
**Post date:** [May 5, 2016, 12:03am UTC](https://forums.unrealengine.com/t/userwidget-added-as-child-always-wrong-size/344962/2 "2016-05-05T00:03:03Z")

</div>

I am not sure this can be answered without knowing some more about your widget. But you should bear in mind that UMG-designer does some layout stuff automatically when placing items, that you might have to do explictly in code/bluepints (i.e taking the slot after you add a child, and setting properties).

---

<div class="post-metadata">

**Author:** ![Stiian](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Stiian](https://forums.unrealengine.com/u/Stiian)\
**Post date:** [September 6, 2022, 7:54pm UTC](https://forums.unrealengine.com/t/userwidget-added-as-child-always-wrong-size/344962/3 "2022-09-06T19:54:13Z")

</div>

Did you solve this? I’m seeing the same issue. I suspect I am missing something important about how layouts are calculated, and that I need a special canvas as root along with proper anchors etc, but I just can’t figure it out…  
My “child” has the size 64x64 in its own Widget-file (an image) (even tried with a SizeBox as root, with overridden 64x64 size), but when I add it to the parent using `->AddChild()` it shows up as 100x30 or something. I’ve tried all combinations of anchors and SizeToContent etc I can think of, but it’s just plain wrong.

---

<div class="post-metadata">

**Author:** ![mnelenpridumivat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mnelenpridumivat/32/1194643_2.png) [@mnelenpridumivat](https://forums.unrealengine.com/u/mnelenpridumivat)\
**Post date:** [September 6, 2022, 8:11pm UTC](https://forums.unrealengine.com/t/userwidget-added-as-child-always-wrong-size/344962/4 "2022-09-06T20:11:50Z")

</div>

I’m not sure if it’s possible to add a child widget to primitives (such as UBorder, UButton and etc) with it’s own size, but for canvas panel you can use `UCanvasPanelSlot* UCanvasPanel::AddChildToCanvas(UWidget* Content)` and after that use `void UCanvasPanelSlot::SetSize(FVector2D InSize)`.  
For example:

```auto
	auto NewSpotRaw = WidgetTree->ConstructWidget<UUserWidgetChild>(UUserWidgetChild::StaticClass()); // create child of UUserWidget
	UCanvasPanelSlot* NewSlot = CanvasPanel->AddChildToCanvas(NewSpotRaw); // add child to canvas panel and save new slot to variable
	NewSlot->SetAlignment({ 0.5f, 0.5f }); // set some settings (pivot of new slot)
	NewSlot->SetPosition(FVector2d(250.0f)); // set another some settings (position on screen)
	NewSlot->SetSize({ 30.0f, 30.0f }); // set size 30x30

```

---

<div class="post-metadata">

**Author:** ![Takanights](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Takanights](https://forums.unrealengine.com/u/Takanights)\
**Post date:** [November 1, 2025, 7:23pm UTC](https://forums.unrealengine.com/t/userwidget-added-as-child-always-wrong-size/344962/5 "2025-11-01T19:23:03Z")

</div>

```auto
This is because when you add a child widget to a panel using Add Child in Blueprint, a slot is added. The default size of a slot is 100x30. After adding a child widget, connect ReturnValue to SetSize and specify the X and Y values.

```

 ![UEExample](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/d/b/edbd8d16e552d1fb42e2b5a3f5dcb82d8d18a43a.png)
