How to create a c++ widget without blueprint child class?
I found these solutions but they don’t work, i guess they’re too old:
https://gist.github.com/SalahAdDin/b3814f109d340f1e0f5dcac6e623b8ce
For this one seems like setting RootWidget doesn’t do anything because in widget reflector it appears same as if NativeConstruct would be empty-There is SObjectWidget with SSpacer inside
Super::NativeConstruct();
UPanelWidget* rootWidget = Cast<UPanelWidget>(GetRootWidget());
auto button = WidgetTree->ConstructWidget<UButton>(UButton::StaticClass());
rootWidget->AddChild(button);
Also this one doesn’t work-GetRootWidget() returns null