Create widget in pure C++
I have read several links regarding creation of widgets in C++. One of them is this:
Unfortunately that was in 2014. It's 2 years from then. So I assume, UE is much better and support many more libraries. So with UI 4.12.5, is it really possible to fully create a simple widget with a simple
Remember, my question is to do that in pure C++. No blueprint widget or any reference to blueprint widget is allowed in here. If you can answer it, please provide the very simple source code in header file and cpp file to enable this. Because I've encountered many people who give unclear answers (without source code) which cannot be compiled or does not solve the problem.
asked Aug 16 '16 at 01:20 PM in C++ Programming
First you create a widget that extends UUserWidget.
Next you override the NativeConstruct method.
In your .cpp file you implement NativeConstruct.
In your PlayerController class create and display the widget.
Now that you have created your base widget in C++ you can start adding components to it. It is extremely important to note that widget components are also widgets. This means you create them in the exact same way you create your UUserWidget.
In your header file define a widget type. In this case I'll define a UButton.
In your CPP file you will instantiate that button.
There are, of course, more steps in this like setting the padding, color, and other properties. It is best that you give your widgets names so you can find them later using using WidgetTree->FindWidget(TEXT("WIDGET_NAME")).
https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Blueprint/UUserWidget/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Blueprint/UWidgetTree/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Components/UButton/index.html
answered Aug 16 '16 at 04:05 PM
So it can be concluded that there is no way to create and manipulate widgets purely in C++ (without UMG or Blueprints). If you created a C++ class derived from
answered Aug 20 '16 at 04:10 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here