it works well when i create one SButton, but if i create two SButton in the same Slot, I would get a compiler error “error C2059: syntax error: ‘’” . So, can I create two or more Slate UI in one Slot? and How to add a SCanvas Panel to my custom Slate UI via C++?
You can declere only one widget in single slot, in order to have more then single widget you need a panel widget. If you ever used UMG you should already understand this concept because UMG inherent this limitation.
So if you want to widget one after nother verticuly you can use SVerticalBox, you add slots to container like this
It looks the same on all container widget each container also have diffrent slot parameters after [] like ].Padding(2.0f) will add padding to slot and for example SCanvas has X and Y position of widget
Now since you seem to lost i will show you how to explore API refrence for how to use widget. All widgets are based from SWidget so you can see whole tree from SWidget page
Now lets pick some widget:
SNew return FArgument of widget you used in SNew, so if you look on FArument in widget page you will see all parameters you can use:
SVerticalBox don’t have parameters only + operator for slots, so check SButton as example
Now in container widgets you can also FSlot which will contain parameters used for single slot:
You can amsle meet some paramters that contain other widget, you already know one in SButton: .Content() ;] some widgets has them more
Now best way to find examples for slate is editor source code, There tool called widget reflector, in Window->Devlopment Tools which let you explore widget tree of editor, so if you wonder how specific widget was done, you scan that widget and you should get name and then you can search it in github to see how this widget got coded.