At the interface of bluprint to C++

In my project I made a widget blueprint and i wanted to show it up up on the viewport so i decided to use a c++ PlayerController class for it, but after a lot of efforts i found out that I cannot directly reference my blueprint assets onto the PlayerController C++ class( correct me if I am wrong here) so i found out that i should make a blueprint with PlayerController class as its parent and add a UPROPERTY to the parent C++ class.

UPROPERTY(EditAnywhere,BlueprintReadWrite)
TSubclassOf<UUserWidget> UserWidget;

And assign the widget blueprint I created into this UPROPERTY

It works absolutely fine, but I would like to know what does the PlayerController blueprint do inorder to make that widget blueprint usable in my C++ code ,that is how does it convert it into a C++ class ( UUserWidget ). Since i created a widget ,and added that widget to the viewport with C++ code only
Sorry for such a long question .

Thats unreal magic, dont worry about it :wink:

If unreal could do that magic in bluprints then why dont they provide a type in C++ so that the magic could be done directly in C++ :))

When you build your game blueprints are translated into C++ code and compiled. This is obviously an amazingly complicated process, but what it means is that the interpretation of blueprints by the editor is just a design-time capability. In the end your C++ is interacting with other C++ code, it is just that the code was generated by the system.

Maybe i wont be able to understand whats going on behind the scenes but It would be good if they could add this functionality directly in c++