How to make a userwidget with ubutton

i have managed to extend my own widget… but i need the userwidget with three ubuttons. just like you extend actor, which may have several components.
can you pls give me some guidance? thanks in advance!

Do you mean that you want to create three buttons in your derived user widget class? well, just override the NativeConstruct function of user widget, and in that function you can get the RootWidget which would be a canvas (unless you have replaced this root widget with something else), the c++ operation to add a child to a panel (canvas is a panel and so are horizontal box, grid box, etc.) is rather similar to the blueprint version, you add a child widget to the panel and it will return a slot in which the child is contained and then you can modify that slot to adjust the layout of the child that you have added.

btw, creating widget object can be done by using the common NewObject function, UMG has a custom “MakeWidget” blueprint node because it needs to add ExposedOnSpawn properties upon construction and also prevent user from entering non transient outer (for a good reason)

1 Like

thanks for you detailed reply~~~