Well, you can have a C++ class and then derive it with a blueprint. This can be an actor, widget or plain UObject or whatever. Usually, this will be the class that creates the widget in question.
In the C++ header, you would have a member like this:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<UUserWidget> MyWidgetClass;
Then when you open the blueprint that derives this C++ class, you would click on “class defaults” at the top. This will open up the details panel and there you can set the Widget class to your widget. This class type will be then be available in C++ so that you can create it in C++ if you so desire.
You may replace UUserWidget type with a C++ widget type if you have one for the widget you are creating. This is optional.