How CreateWidget() works?

I know, a bit silly question, but how it works? In documentation there are only arguments, but I don’t understand the way it works. And if it’s possible, please help with this problem:
.h:

UCustomUserWidget* FadeWidget;
...
UPROPERTY(EditDefaultsOnly, Category = "Widgets")
		TSubclassOf<UCustomUserWidget> FadeWidgetClass;

.cpp:

FadeWidget = CreateWidget<UCustomUserWidget>(GetWorld(), FadeWidgetClass);

And it says CreateWidget called with a null class about FadeWidgetClass.
UCustomUserWidget is c++ class that I created.

If your cpp line is in constructor, then at this point FadeWidgetClass is still nullptr, even if it’s defined in derived blueprint.

If this is the case, then I can suggest to move this initialization in any moment later, for example on BeginPlay

It is placed on BeginPlay in my PlayerController file.

Are you sure you have assigned FadeWidgetClass in the editor? I think it is null

No, I didn’t.

  1. I don’t understand what is FadeWidgetClass in CreateWidget() arguments, could you, please, explain why do I need it?
  2. How to assign class in the EDITOR, and what do I need to have in this assignment?

Finally, I found how to do it. I know, maybe I’m stupid, because I didn’t find it before. Here it is. I just had to set it in Class Defaults of my BP Player Controller to BP subclass of my CustomUserWidget:
Untitled