# Store reference to child widgets?

**URL:** <https://forums.unrealengine.com/t/store-reference-to-child-widgets/422069>\
**Category:** C++\
**Tags:** unreal-engine, UE4, CPP, question\
**Created:** [April 7, 2018, 6:25pm UTC](https://forums.unrealengine.com/t/store-reference-to-child-widgets/422069 "2018-04-07T18:25:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Inconceivable](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Inconceivable](https://forums.unrealengine.com/u/Inconceivable)\
**Post date:** [April 7, 2018, 6:25pm UTC](https://forums.unrealengine.com/t/store-reference-to-child-widgets/422069/1 "2018-04-07T18:25:33Z")

</div>

I have a UUserWidget derived base class. I create one in the editor, add a panel, and add some TextBlock and Button widgets. I want to keep track of an array of “important” widgets among these TextBlocks and Buttons.

I tried exposing an array like this:

```
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
TArray<UWidget*> ImportantWidgets;

```

But of course, like everything, this resulted in a headache. That array is visible in the base’s properties, but I can’t assign anything to it. I add an element and try to assign the asset, but none of the TextBlocks or Buttons show up.

---

<div class="post-metadata">

**Author:** ![MrMcKvarz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrMcKvarz](https://forums.unrealengine.com/u/MrMcKvarz)\
**Post date:** [April 10, 2018, 2:34pm UTC](https://forums.unrealengine.com/t/store-reference-to-child-widgets/422069/2 "2018-04-10T14:34:21Z")

</div>

Try to use `TArray<TSubclassOf<UWidget>> ImportantWidgets`.

---

<div class="post-metadata">

**Author:** ![disseminate](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/disseminate/32/987805_2.png) [@disseminate](https://forums.unrealengine.com/u/disseminate)\
**Post date:** [December 1, 2018, 5:16pm UTC](https://forums.unrealengine.com/t/store-reference-to-child-widgets/422069/3 "2018-12-01T17:16:47Z")

</div>

That’s for storing a reference to a class, not the widget object itself.

I’m having this issue too (4.21). If I use a TArray, I can set elements but they’re wiped when the widget is compiled. If I just use pointers, I can’t set them at all.

The only solution I’ve found is to use GetWidgetFromName but this significantly hampers reusability.

---

<div class="post-metadata">

**Author:** ![NoCodeBugsFree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NoCodeBugsFree](https://forums.unrealengine.com/u/NoCodeBugsFree)\
**Post date:** [December 1, 2018, 6:10pm UTC](https://forums.unrealengine.com/t/store-reference-to-child-widgets/422069/4 "2018-12-01T18:10:11Z")

</div>

Hi. Fill your array in event consctruct like this:

> **[blueprintUE | PasteBin For Unreal Engine 4](https://blueprintue.com/)**
>
> blueprintUE is a tool for sharing, rendering and rating blueprints for Unreal Engine 4. UE4 is a game engine which use visual scripting called blueprint.

p.s.

```
/** health bar reference */
UPROPERTY(meta = (BindWidget), VisibleAnywhere, BlueprintReadWrite)
class UProgressBar* Health;

/** shield bar reference */
UPROPERTY(meta = (BindWidget), VisibleAnywhere, BlueprintReadWrite)
class UProgressBar* Shield;
```
