# What are some general use-cases for the SWeakWidget type?

**URL:** <https://forums.unrealengine.com/t/what-are-some-general-use-cases-for-the-sweakwidget-type/278319>\
**Category:** Getting Started & Setup\
**Tags:** unreal-engine, question\
**Created:** [March 25, 2014, 3:38am UTC](https://forums.unrealengine.com/t/what-are-some-general-use-cases-for-the-sweakwidget-type/278319 "2014-03-25T03:38:49Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![anonymous\_user\_0dc1700e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0dc1700e](https://forums.unrealengine.com/u/anonymous_user_0dc1700e)\
**Post date:** [March 31, 2014, 1:20pm UTC](https://forums.unrealengine.com/t/what-are-some-general-use-cases-for-the-sweakwidget-type/278319/3 "2014-03-31T13:20:49Z")

</div>

So, given this information. What is the point of giving the SWeakWidget to the viewport?

```
GEngine->GameViewport->
AddViewportWidgetContent(SNew(SWeakWidget).
PossiblyNullContent(MyUIWidget.ToSharedRef()));

```

Am I wrong to assume that the reason we don’t give the Viewport a SharedPtr is because we don’t want it to be a form of “life support” for the widget it’s being given a “handle” on?

In this example MyUIWidget is a SCompoundWidget, the “master” widget so to speak, of which all other widgets are children. I guess that by “making sure the widget’s life time is managed in a central place elsewhere”, that is in this example, “elsewhere” is the HUD, which has a SCompoundWidget SharedPtr named MyUIWidget.

By keeping the Viewport from being a source of “life support” we make sure the widgets are dead when the HUD is dead (for example if we changed/killed the HUD from memory but kept the same Viewport), correct?

I think I understand your explanation, I just find it helpful to have a concrete example or two to solidify my understanding. Once I understand a what you’re saying within the context of an idiom or two I’ll not need to bugger you for input every time, so please correct me if I’m wrong. If you need some background on the above code, it’s part of my Hello Slate tutorial here.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

I try to support the community when I can, if you do humor me the “buck won’t stop here.” I’m planning to update the Hello Slate tutorial soon, I had a hardware failure recently and it’s caused a bit of a setback. Luckily I was publishing all my research on this site so it’s all pretty well documented =)

---

_[View the full topic](https://forums.unrealengine.com/t/what-are-some-general-use-cases-for-the-sweakwidget-type/278319)._
