Cast to UUserWidget class from C++
The task is to initiate the custom Event in the widget to refresh some variables.
I created a C++ class derived from the UUserWidget
Widget BP is derived from this class. I found this event and used it in the BP. No any issues.
Next step is initiate this event from others C++ classes. I tried todo next
And somewhere in the functions
Cast does not work. Probably I need to declare UContainerWidgetUpdate();
The question is how to cast to the UUserWidget class from other C++ classes. May be this is a wrong approach.
asked Aug 31 '17 at 08:10 PM in C++ Programming
Yes, the cast is incorrect. This is the syntax:
In return you get a pointer which is either "nullptr" if cast failed or a pointer of "TargetClass".
So, in your case:
Note: You should always check if cast has failed, otherwise it's very likely you will get crashes.
Follow this question
Once you sign in you will be able to subscribe for any updates here