Dynamically create UMG widgets (subclass of UUserWidget) in C++?

Hey guys,

I’m trying to create my subclass of UUserWidget (UTargetInfoWidget) in C++.

How should I go about this? doesn’t seem to like widgets, and you can’t instantiate UObjects without some sort of constructing object (UWorld, GEngine, etc). Additionally, suggests that the return be stored in a TSharedPtr or TSharedRef, which you can’t use for UObjects.

Any ideas?

Thanks.

In 4.5 there are some CreateWidget<T> global functions you can use. For 4.4, probably best to use the same one Blueprints use, UWidgetBlueprintLibrary::Create. is for Slate widgets, you wont use it at all in UMG unless you’re implementing a new primitive (non-uuserwidget) widget, that wraps an existing Slate widget.

As for extending UUserWidget in C++, you’re in luck there’s a good tutorial here, https://forums.unrealengine.com/showthread.php?38097-Tutorial-Extend-UUserWidget-for-UMG