UMG: How to create default buttons

I’m trying to extend UUserWidget in order to create an in game menu that I can manipulate with both C++ and blueprint. I’ve got my base class compiling, but I’m attempting to add a series of buttons to my widget that will auto populate when I create a new blueprint, akin to a default sub object in an object blueprint.
As such, I am working in the constructor, trying to create the button widgets and see them in the widget blueprint editor.

I have tried CreateDefaultSubobject, but that doesn’t add them to the Canvas.

I have tried GetSlotNames(), but it causes an access violation.

I have tried to access the Canvas directly, but can’t find where it has been added, as it is not referenced in either UUserWidget() or UWidget(), and if I do GetWidgetFromName(FName(TEXT(“Canvas Panel”))), I get an access violation.

Supposedly I can call AddChild, but UUserWidget has no such function, nor can I find one.
Does anyone know how to solve this issue?

The way i combine blueprints and C++ for umg is by creating widgets derived from UWidget in C++. Afterwards i combine them in blueprints, which is much easier. I would advise you to do the same thing. You can build slate style widgets this way and expose them to blueprints. You just have to implement the method RebuildWidget(), in the constructor of the class you can initialize some data, but the widget itself has to be build in the RebuildWidget method. Using this method i build things like serverlists, custom comboboxes etc. You can easily add a few default widgets the RebuildWidget methods if you would like to do that.

Interesting. I’ll have to do my homework on Slate, then. Still not sure what the difference between UWidget and SWidget, but I’ll look into it. Thank you.

How can we add the buttons to a UUserWidget c++ class?