# GetDesiredSize of Text Widget Return 0

**URL:** <https://forums.unrealengine.com/t/getdesiredsize-of-text-widget-return-0/378015>\
**Category:** UI\
**Tags:** size, text, unreal-engine, Widget, question\
**Created:** [December 1, 2016, 2:49pm UTC](https://forums.unrealengine.com/t/getdesiredsize-of-text-widget-return-0/378015 "2016-12-01T14:49:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pelangi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pelangi](https://forums.unrealengine.com/u/Pelangi)\
**Post date:** [December 1, 2016, 2:49pm UTC](https://forums.unrealengine.com/t/getdesiredsize-of-text-widget-return-0/378015/1 "2016-12-01T14:49:02Z")

</div>

Is it true that text widget in Blueprint, GetDesiredSize() always return zero regardless of any text entered in that widget?

Here’s an unresolved issue as well:

> **[Get size of UMG widget](https://forums.unrealengine.com/questions/440493/get-size-of-umg-widget.html)**
>
> Hey, I want to get the size of a widget inside a child class of UHorizontalBox in C++. Is that possible? GetDesiredSize() always returns 0 and I hadn't have any luck with with anything else I tried so far.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e729f54e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e729f54e](https://forums.unrealengine.com/u/anonymous_user_e729f54e)\
**Post date:** [December 1, 2016, 4:34pm UTC](https://forums.unrealengine.com/t/getdesiredsize-of-text-widget-return-0/378015/2 "2016-12-01T16:34:07Z")

</div>

Hello Pelangi,

After doing a bit of digging I was able to find a post with information on this subject. I have provided a link below. I hope that this information helps. As a note, you maybe getting a return of zero because the the widget has not been fully added to the screen when you are calling “Get Desired Size”. There is a chance that calling this on Event Construct will return 0,0 because it is being called before the widget you are testing has been fully added. As a test you can call this on tick to see if you are given any values. As stated above, see the linked thread for more information.

Link: [UMG Widget GetDesiredSize() - UI - Epic Developer Community Forums](https://answers.unrealengine.com/questions/149473/umg-widget-getdesiredsize.html)

Make it a great day

---

<div class="post-metadata">

**Author:** ![MarcoMariaRossi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marcomariarossi/32/1069093_2.png) [@MarcoMariaRossi](https://forums.unrealengine.com/u/MarcoMariaRossi)\
**Post date:** [June 3, 2019, 8:48am UTC](https://forums.unrealengine.com/t/getdesiredsize-of-text-widget-return-0/378015/3 "2019-06-03T08:48:19Z")

</div>

This can be remedied by using “Force Layout Prepass” before “get desired size”

---

<div class="post-metadata">

**Author:** ![CupofCoffee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CupofCoffee](https://forums.unrealengine.com/u/CupofCoffee)\
**Post date:** [June 29, 2022, 2:10pm UTC](https://forums.unrealengine.com/t/getdesiredsize-of-text-widget-return-0/378015/4 "2022-06-29T14:10:45Z")

</div>

thank you  
that was helpful

---

<div class="post-metadata">

**Author:** ![machinecommune](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@machinecommune](https://forums.unrealengine.com/u/machinecommune)\
**Post date:** [November 21, 2022, 3:24pm UTC](https://forums.unrealengine.com/t/getdesiredsize-of-text-widget-return-0/378015/5 "2022-11-21T15:24:20Z")

</div>

This worked for me in UE4.26 on a rich text block. The rich text block is inside a canvas panel and is set to auto-size and auto word wrap.

Header:

// The rich text block to use for displaying the text.  
UPROPERTY(Transient, meta = (BindWidget))  
URichTextBlock\* DynamicRichTextBlock;

CPP:

DynamicRichTextBlock-\>ForceLayoutPrepass();  
UE\_LOG(LogTemp, Warning, TEXT(“DynamicRichTextBlockSize %s”), \*DynamicRichTextBlock-\>GetDesiredSize().ToString());  
return DynamicRichTextBlock-\>GetDesiredSize();

---

<div class="post-metadata">

**Author:** ![etiq](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/etiq/32/949272_2.png) [@etiq](https://forums.unrealengine.com/u/etiq)\
**Post date:** [October 25, 2024, 9:42am UTC](https://forums.unrealengine.com/t/getdesiredsize-of-text-widget-return-0/378015/6 "2024-10-25T09:42:17Z")

</div>

Thank you a lot!

---

<div class="post-metadata">

**Author:** ![rit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rit](https://forums.unrealengine.com/u/rit)\
**Post date:** [December 3, 2024, 11:08am UTC](https://forums.unrealengine.com/t/getdesiredsize-of-text-widget-return-0/378015/7 "2024-12-03T11:08:42Z")

</div>

I was stuck on this issue for a whole day!  
Thanks for providing a solution and a comprehensive explanation man!
