Question
From within a UserWdiget c++ class how can you assign its root to another widget. From within a UserWdiget c++ class, how can you assign that class’s root a widget like a button widget or horizontal box.
Lets call this example UserWidget “WidgetA” and lets say that I want to add a button widget to always be the root of WidgetA.
How can I make it so that whenever I make a c++ subclass or blueprint subclass of WidgetA, the root widget of the WidgetA subclass is always a button?
What I tried
UOptionStepper::UOptionStepper(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {
NewRootButton = WidgetTree->ConstructWidget<UButton>(UButton::StaticClass(), TEXT("RootButton"));
if (NewRootButton )
WidgetTree->RootWidget = NewRootButton ;
}
What I tried will compile but when I create a BP of UOptionStepper, nothing is its root element.
Thanks in advance