SUserWidget

Use [SUserWidget](API\Runtime\SlateCore\Widgets\SUserWidget) as a base class to build aggregate widgets that are not meant to serve as low-level building blocks.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

SlateCore

Header

/Engine/Source/Runtime/SlateCore/Public/Widgets/SUserWidget.h

Include

#include "Widgets/SUserWidget.h"

Syntax

class SUserWidget : public SCompoundWidget

Remarks

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() ); }

Functions

Name Description

Protected function

void

 

Construct

(
    const FArguments& InArgs
)

Operators

Name Description

Protected function

void *

 

operator new

(
    const size_t InSize
)

User widgets can be allocated explicitly in the C++

Classes

Name

Description

Public struct

FArguments

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss