Module |
|
Header |
/Engine/Source/Runtime/SlateCore/Public/Widgets/SUserWidget.h |
Include |
#include "Widgets/SUserWidget.h" |
class SUserWidget : public SCompoundWidget
Use SUserWidget as a base class to build aggregate widgets that are not meant to serve as low-level building blocks. Examples include: a main menu, a user card, an info dialog for a selected object, a splash screen.
See SUserWidgetExample
SMyWidget.h
class SMyWidget : public SUserWidget { public: SLATE_USER_ARGS( SMyWidget ) {} SLATE_END_ARGS()
MUST Provide this function for SNew to call! virtual void Construct( const FArguments& InArgs ) = 0;
virtual void DoSomething() = 0; };
SMyWidget.cpp
namespace Implementation { class SMyWidget : public ::SMyWidget { public: virtual void Construct( const FArguments& InArgs ) override { SUserWidget::Construct](API\Runtime\SlateCore\Widgets\SUserWidget\FArguments) [ SNew(STextBlock) .Text( NSLOCTEXT("x", "x", "My Widget's Content") ) ] }
private: Private implementation details can occur here without ever leaking out into the .h file! } }
TSharedRef<SMyWidget> SMyWidget::New() { return MakeShareable( new SMyWidget() ); }
Name | Description | ||
---|---|---|---|
|
Construct ( |
Name | Description | ||
---|---|---|---|
|
void * |
operator new ( |
User widgets can be allocated explicitly in the C++ |
Name |
Description |
|
---|---|---|
|
FArguments |