How can I create a compound widget in c++ then add it to a UMG(UUSerWidget) Canvas?

I need to create widgets in c++ which I have done by extending UWidget but inside this widget I need to have 2 widgets ie. a compound widget. so I have some TSubobjectPtrs to contain those widgets within this new one. But when I add that widget in a UMG blueprint it is just empty. How can I get my compound widget to display it’s subwidgets?

You’d want to be inheriting SCompoundWidget in your C++ class, and adding child widgets via its ChildSlot rather than using subobject pointers.