BindWidget Null when using Create Widget

how can I call the CreateWidget function for blueprint classes in C++?

SomeWidget = CreateWidget(YourPlayerController, USomeWidget::StaticClass());

This is not correct, you need to pass the blueprint class, not C++ static class. If you pass the C++ static class, then none of the bindings will work.

One way to get the blueprint class is to add a TSubclassOf UPROPERTY and then pick the appropriate widget blueprint in the editor.

	UPROPERTY(EditAnywhere, Category = "UI")
		TSubclassOf<class UNoteWidget> noteWidgetClass;
UNoteWidget* noteWidget = CreateWidget<UNoteWidget>(YourPlayerController, noteWidgetClass);
2 Likes