How do I create buttons dynamically in a widget?

Disclaimer: New to UE, previously worked on Unity and really struggling with the whole Blueprints thing.

I want to create a widget that will display a number of buttons on the screen.

The thing is, the number is dynamic, I want to get it from the user (as the game develops the number will change, affected by user’s actions, so I want a method that will set the variable controlling this).

How the hell am I supposed to do that?? Every guide I find online is basically telling me to add a loop and then in the loop’s body to create an “Add Button” but there is no such thing.

I desperately want to just write it in code and “throw” it on the Canvas Panel (I have a Scale Box inside that should hold all the buttons and stretch dynamically based on the number of buttons added), but I can’t find anywhere how to do it. Moreover, it seems like I can’t find a way to reach the functions I’m creating in the Blueprint via my IDE!

Please help :frowning: I really wish to understand how to work with UE5 as a developer.

Thanks upfront :slight_smile:

Loops is the way to go. You can store an array of structures that hold information about the buttons on some actor, or the game instance, and then use that for the loop to get the data you need for each button. I was going to suggest a data table, but I don’t think you can modify them in runtime

Also the scale box holds only one thing, so you should put a horizontal/vertical box inside it and dump the buttons there