How to add custom widget in scrollbox on c++

I had a problem when trying to add a widget to the Scrollbox. Widget inherited from the UuserWidget class. Such a widget is well added in the designer, but in c++ code I can not find in any way how to do this. Help me, please

I hope you can “read” C++ Slate code because it would look something like this:

SNew(SScrollBox)  
+ SScrollBox::Slot()
[ 
  MyCustomWidget.ToSharedRef()
];

which doesn’t make a lot of sense until you’ve gotten your hands dirty with Slate and wrapped your head around how it does construction. :slight_smile:

There’s a great overview of Slate C++ wise here.

Are there other ways to solve the problem, besides the use slate? It’s worth noting that even in the blueprints I could not find how to add a custom widget to the scrollbox.

Ah, you mean UMG (which is technically built on top of Slate IIRC, so the calls are similar):

UScrollBox* MyScrollBox; // I'm going to assume this is created somewhere either through the UMG Designer or through a NewObject call.

MyScrollBox->AddChild( MyCustomWidget ); // Where MyCustomWidget is the widget you want to add to the scrollbox

Thanks, I figured it out. It turns out that the problem was that the ScrollBox-> AddChild () function can not have a parameter UUserWidget. With CanvasPanel this function work well.