# How can I get the size of a widget in UMG?

**URL:** <https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341>\
**Category:** UI\
**Tags:** size, scrollbox, unreal-engine, Widget, question, UMG\
**Created:** [May 21, 2015, 12:57pm UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341 "2015-05-21T12:57:41Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_f5d62403](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f5d62403](https://forums.unrealengine.com/u/anonymous_user_f5d62403)\
**Post date:** [May 21, 2015, 12:57pm UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/1 "2015-05-21T12:57:41Z")

</div>

I want to custom a scrollbox ,but I can not get the size of my scrollbox and the widget I put in it, I guess "I just want to get the size of a widget " that mey be a simple question, please! who can help me? and forgive my bad english.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8e2766aa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8e2766aa](https://forums.unrealengine.com/u/anonymous_user_8e2766aa)\
**Post date:** [May 21, 2015, 1:29pm UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/2 "2015-05-21T13:29:42Z")

</div>

Hello, libohan1312

To do this, you can use UUserWidget::SetDesiredSizeInViewport function:

```
UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category="User Interface|Viewport")
void SetDesiredSizeInViewport (FVector2D Size)

```

Hope this helped!

Good luck!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f5d62403](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f5d62403](https://forums.unrealengine.com/u/anonymous_user_f5d62403)\
**Post date:** [May 22, 2015, 1:56am UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/3 "2015-05-22T01:56:46Z")

</div>

Thinks , do you mean that get the size manually? can I get it dynamic in the running time? I hava extended the scrollbox, I want to get the size of the widget added in it.

---

<div class="post-metadata">

**Author:** ![ThePerfectFlaw](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThePerfectFlaw](https://forums.unrealengine.com/u/ThePerfectFlaw)\
**Post date:** [July 24, 2015, 10:46am UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/4 "2015-07-24T10:46:02Z")

</div>

Hey Libohan,

I may have found a way to get the size of a widget but its a little long winded to get there. Basically put your widget within a container, like a vertical or horizontal box. Make that container a variable so you can get it’s size.

 ![51306-get+widget+size.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/8/2/a82744228324fe45f7c8760e1a56a9d7fa7b6c8c.png)

I hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f5d62403](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f5d62403](https://forums.unrealengine.com/u/anonymous_user_f5d62403)\
**Post date:** [July 28, 2015, 3:49am UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/5 "2015-07-28T03:49:08Z")

</div>

yes! I think it works , I find only canvas solt can get it`s children`s size, thanks.

---

<div class="post-metadata">

**Author:** ![delcasda](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@delcasda](https://forums.unrealengine.com/u/delcasda)\
**Post date:** [May 26, 2018, 5:48pm UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/6 "2018-05-26T17:48:57Z")

</div>

this works perfect

---

<div class="post-metadata">

**Author:** ![tommybazar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tommybazar](https://forums.unrealengine.com/u/tommybazar)\
**Post date:** [May 12, 2021, 6:06am UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/7 "2021-05-12T06:06:41Z")

</div>

Best way in cpp is

```
GetCachedGeometry().GetLocalSize()

```

Or in BPs :

![338594-untitled.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/6/e5687fbf9680eb53c8e5fcb90a8694a663337a5f.png)

---

<div class="post-metadata">

**Author:** ![zgzg2020](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zgzg2020](https://forums.unrealengine.com/u/zgzg2020)\
**Post date:** [February 2, 2022, 9:08am UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/8 "2022-02-02T09:08:43Z")

</div>

I cannot open the BP link ☹

---

<div class="post-metadata">

**Author:** ![Kavan](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kavan/32/1194623_2.png) [@Kavan](https://forums.unrealengine.com/u/Kavan)\
**Post date:** [February 18, 2022, 11:57pm UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/9 "2022-02-18T23:57:44Z")

</div>

Another way, one that worked best for me, was to use the “Get Scroll Offset Of End” node from my scrollbox and use that as a clamp on the offset I applied via my input.

Input \* scrollSpeed + GetScrollOffset (current offset) → Clamped between 0 (top of scrollbox) and GetScrollOffsetOfEnd (end of scrollbox) → pipe return into SetScrollOffset node.

---

<div class="post-metadata">

**Author:** ![tommybazar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tommybazar](https://forums.unrealengine.com/u/tommybazar)\
**Post date:** [February 23, 2022, 2:05am UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/10 "2022-02-23T02:05:29Z")

</div>

Blueprint : Get Cached Geometry (returns a Geometry), Get Local Size (takes in a geometry) …

---

<div class="post-metadata">

**Author:** ![JayChang-zhe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JayChang-zhe](https://forums.unrealengine.com/u/JayChang-zhe)\
**Post date:** [March 29, 2022, 4:13am UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/11 "2022-03-29T04:13:36Z")

</div>

Really nice one, thanks

---

<div class="post-metadata">

**Author:** ![JDARRAS](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jdarras/32/619913_2.png) [@JDARRAS](https://forums.unrealengine.com/u/JDARRAS)\
**Post date:** [October 29, 2022, 1:02am UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/12 "2022-10-29T01:02:37Z")

</div>

Hello @anonymous_user_8e2766aa  
Can you tell me how you can do that ?  
Is it a node in a blueprint or it’s C++ ?

Thanks for your help  
JD

---

<div class="post-metadata">

**Author:** ![lmperitum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lmperitum](https://forums.unrealengine.com/u/lmperitum)\
**Post date:** [April 4, 2023, 2:52pm UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/13 "2023-04-04T14:52:48Z")

</div>

It is works only after 1-2 frames after widget construction

---

<div class="post-metadata">

**Author:** ![tomasz73j](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tomasz73j](https://forums.unrealengine.com/u/tomasz73j)\
**Post date:** [December 20, 2023, 7:44pm UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/14 "2023-12-20T19:44:22Z")

</div>

In c++ you can use:  
`FVector2D WidgetSize = Widget->GetDesiredSize();`

But if this widget is created in this frame you should wait frame before you be abble to use it. Other way you get WidgetSize = { 0 , 0 }.

To wait frame you can for example use FTimerHandle.

(1.) In .h file add to your UCLASS

- `bool HasWaitedFrame { false };`
- And add function `void DoSomethingInNextFrame();`

(2.) .cpp

```auto
void UYourClass ::DoSomethingInNextFrame();
{
   if ( ! HasWaitedFrame )
   {	
     FTimerHandle timerhandler;
     GetWorld() ->GetTimerManager() .SetTimer( timerhandler , [this]() { HasWaitedFrame = true; DoSomethingInNextFrame( ); } , 0.01f , false );	
   }
   else
   {
      FVector2D WidgetSize = Widget ->GetDesiredSize();
      // Do something more
   }

```

(3) All you must do is call this function when you want to DoSomethingInNextFrame

---

<div class="post-metadata">

**Author:** ![X-perto](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@X-perto](https://forums.unrealengine.com/u/X-perto)\
**Post date:** [October 27, 2024, 7:40pm UTC](https://forums.unrealengine.com/t/how-can-i-get-the-size-of-a-widget-in-umg/319341/15 "2024-10-27T19:40:14Z")

</div>

Legend
