# Using pure C++ UUserWidget inside of another BP widget in UMG editor 

**URL:** <https://forums.unrealengine.com/t/using-pure-c-uuserwidget-inside-of-another-bp-widget-in-umg-editor/2644733>\
**Category:** UI\
**Tags:** unreal-engine, question\
**Created:** [August 17, 2025, 1:53pm UTC](https://forums.unrealengine.com/t/using-pure-c-uuserwidget-inside-of-another-bp-widget-in-umg-editor/2644733 "2025-08-17T13:53:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Misha](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Misha](https://forums.unrealengine.com/u/Misha)\
**Post date:** [August 17, 2025, 1:53pm UTC](https://forums.unrealengine.com/t/using-pure-c-uuserwidget-inside-of-another-bp-widget-in-umg-editor/2644733/1 "2025-08-17T13:53:44Z")

</div>

How to create UUserWidget and populate it with widgets in C++?  
For example, create UUserWidget, then create and add Text Box to it

I’ve tried to WidgetTree-\>CosntructWidget and assigning it to WidgetTree-\>RootWidget inside NativeOnInitialized/NativeConstruct/NativePreConstruct, like so:

```auto
// .h
UCLASS()
class PURECPPWIDGET_API UMyUserWidget : public UUserWidget
{
	GENERATED_BODY()

public:
	UCanvasPanel* CanvasPanel;

private:
	void NativeOnInitialized() override;
	void NativeConstruct() override;
	void NativePreConstruct() override;

	void CreateWidgets();
};

// .cpp
void UMyUserWidget::NativeOnInitialized()
{
	UE_LOG(LogTemp, Warning, TEXT("UMyUserWidget::NativeOnInitialized before"));
	Super::NativeOnInitialized();

	CreateWidgets();
}

void UMyUserWidget::NativeConstruct()
{
	UE_LOG(LogTemp, Warning, TEXT("UMyUserWidget::NativeCosntruct"));
	Super::NativeConstruct();
}

void UMyUserWidget::NativePreConstruct()
{
	UE_LOG(LogTemp, Warning, TEXT("UMyUserWidget::NativePreConstruct"));
	Super::NativePreConstruct();
}

void UMyUserWidget::CreateWidgets()
{
	UE_LOG(LogTemp, Warning, TEXT("UMyUserWidget::CreateWidgets before"));

	CanvasPanel = WidgetTree->ConstructWidget<UCanvasPanel>(UCanvasPanel::StaticClass());
	if (!CanvasPanel)
		return;

	auto textBlock = WidgetTree->ConstructWidget<UTextBlock>(UTextBlock::StaticClass());
	textBlock->SetText(FText::FromString("Hello World!"));
	CanvasPanel->AddChildToCanvas(textBlock);

        // WidgetTree->RootWidget = textBlock;
	WidgetTree->RootWidget = CanvasPanel;

	UE_LOG(LogTemp, Warning, TEXT("UMyUserWidget::CreateWidgets after"));
}

```

But when I add My User Widget in UMG editor, nothing is visible

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/a/1ba5a5dec550634c85891f85254572a49b2ca983.png)

---

<div class="post-metadata">

**Author:** ![Dasay2605](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dasay2605](https://forums.unrealengine.com/u/Dasay2605)\
**Post date:** [August 17, 2025, 5:47pm UTC](https://forums.unrealengine.com/t/using-pure-c-uuserwidget-inside-of-another-bp-widget-in-umg-editor/2644733/2 "2025-08-17T17:47:40Z")

</div>

I think a similar question has already been asked and answered in [this](https://forums.unrealengine.com/t/create-widget-in-pure-c/367306) thread.

---

<div class="post-metadata">

**Author:** ![Misha](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Misha](https://forums.unrealengine.com/u/Misha)\
**Post date:** [August 17, 2025, 5:58pm UTC](https://forums.unrealengine.com/t/using-pure-c-uuserwidget-inside-of-another-bp-widget-in-umg-editor/2644733/3 "2025-08-17T17:58:23Z")

</div>

Yeah, and I’ve tried the solution from there but it doesn’t work [Create widget in pure C++ - #41 by isaac4096](https://forums.unrealengine.com/t/create-widget-in-pure-c/367306/41)

---

<div class="post-metadata">

**Author:** ![AlienRenders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlienRenders](https://forums.unrealengine.com/u/AlienRenders)\
**Post date:** [August 17, 2025, 6:41pm UTC](https://forums.unrealengine.com/t/using-pure-c-uuserwidget-inside-of-another-bp-widget-in-umg-editor/2644733/4 "2025-08-17T18:41:23Z")

</div>

I remember trying to do this a while back and gave up. The only thing I’ve seen since is trying to tell the editor that the widget hierarchy has been modified. You’ll need to call Modify() on every asset you’ve added and every parent in the hierarchy.

```auto
    UWidgetBlueprintGeneratedClass* wbpClass = Cast<UWidgetBlueprintGeneratedClass>(WidgetTree->RootWidget->GetClass());
    UWidgetBlueprint* asset = Cast<UWidgetBlueprint>(wbpClass->GetPackage()->FindAssetInPackage());

    asset->Modify();

    // Tell editor that blueprint has changed.
    FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(asset);

```

I have no clue if this will work but thought I’d mention it as it’s easy enough to try.

---

<div class="post-metadata">

**Author:** ![Dasay2605](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dasay2605](https://forums.unrealengine.com/u/Dasay2605)\
**Post date:** [August 18, 2025, 5:03pm UTC](https://forums.unrealengine.com/t/using-pure-c-uuserwidget-inside-of-another-bp-widget-in-umg-editor/2644733/5 "2025-08-18T17:03:24Z")

</div>

I won’t lie, I should have checked that thread before suggesting it, as it doesn’t even have a proper answer to the OP’s problem. I just saw a post with 13 likes and was convinced it should work.  
I found a [site](https://unreal-garden.com/tutorials/build-widgets-in-editor/) that seems to do what you’re asking. I tested it myself, and it seems to work (sort of).

---

<div class="post-metadata">

**Author:** ![AlienRenders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlienRenders](https://forums.unrealengine.com/u/AlienRenders)\
**Post date:** [August 19, 2025, 4:25am UTC](https://forums.unrealengine.com/t/using-pure-c-uuserwidget-inside-of-another-bp-widget-in-umg-editor/2644733/6 "2025-08-19T04:25:44Z")

</div>

The whole point is not to use BindWidget.

> [@anonymous\_user\_1fc5ed87](#):
>
> **problem 2:**  
> The pointer is not initialized as nullptr. This can lead to undefined behavior.

Quoting the docs:

> [@](#):
>
> `UObjects` are automatically zeroed on initialization, before the constructor is called. This happens for the whole class, `UProperties` and native members alike.

From the docs here:

> **[Unreal Object Handling in Unreal Engine | Unreal Engine 5.6 Documentation |...](https://dev.epicgames.com/documentation/en-us/unreal-engine/unreal-object-handling-in-unreal-engine)**
>
> Overview of the features of the UObject system.

> [@anonymous\_user\_1fc5ed87](#):
>
> Mark the property as private or protected when possible.

Debatable. I’ve been a programmer for over 40 years. I’m not a fan of this blanket strategy. But this is another topic.

---

<div class="post-metadata">

**Author:** ![Misha](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Misha](https://forums.unrealengine.com/u/Misha)\
**Post date:** [August 23, 2025, 8:11am UTC](https://forums.unrealengine.com/t/using-pure-c-uuserwidget-inside-of-another-bp-widget-in-umg-editor/2644733/7 "2025-08-23T08:11:01Z")

</div>

> [@AlienRenders](#):
>
> The whole point is not to use BindWidget.

Yeah, this

It’s a really good thing to use BindWidget when there’s a need to change anything in UMG editor

But when you just want to have a wrapper for a widget (UTextBlock in my case), then you really don’t want those extra steps with BindWidget
