Navigation
API > API/Runtime > API/Runtime/SlateCore
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 SUserWidgetExampleSMyWidget.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( 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
| Name | SUserWidget |
| Type | class |
| Header File | /Engine/Source/Runtime/SlateCore/Public/Widgets/SUserWidget.h |
| Include Path | #include "Widgets/SUserWidget.h" |
Syntax
class SUserWidget : public SCompoundWidget
Inheritance Hierarchy
- FSharedFromThisBase → TSharedFromThis → SWidget → SCompoundWidget → SUserWidget
- FSlateControlledConstruction → SWidget → SCompoundWidget → SUserWidget
Derived Classes
Structs
| Name | Remarks |
|---|---|
| FArguments |
Functions
Public
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Construct
(
const FArguments& InArgs |
Widgets/SUserWidget.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void operator delete
(
void* InMem |
This exists to silence V1062 and provide implementation balance with the new above. | Widgets/SUserWidget.h | |
void * operator new
(
const size_t InSize |
User widgets can be allocated explicitly in the C++ | Widgets/SUserWidget.h |