Download

Add UWidget to WidgetTree

Hey folks,

anyone figured out how to create and add a Widget to a Widgettree which is visible in designer tab?

I just tried the following and it seems that the button is valid. But i miss something to really make the button visible and editable in designertab
of the MyUserWidget derived blueprint.




void UMyUserWidget::OnWidgetRebuilt()
{	
	Super::OnWidgetRebuilt();	

	// TODO: would like to create the widgets in c++, not working yet
	if (WidgetTree)
	{
		TSubclassOf<UButton> BtnClass = UButton::StaticClass();

		Button = WidgetTree->ConstructWidget<UButton>(BtnClass, FName("Button"));		
	}
}



any help appreciated :wink:

Asked the same thing, never got an answer. Havent looked into it since. What i did was using an iterator to serach trough all widgets and find the one i wanted to use in code by nameā€¦ this forced me to layout a widget and then put the code inside

yeah sure, using the iterator solution try cast to my WidgetClass works well, i was just wondering if that is also possible this way.