# 'WidgetStyle': undeclared identifier

**URL:** <https://forums.unrealengine.com/t/widgetstyle-undeclared-identifier/355806>\
**Category:** UI\
**Tags:** style, unreal-engine, Widget, question\
**Created:** [April 28, 2016, 5:35pm UTC](https://forums.unrealengine.com/t/widgetstyle-undeclared-identifier/355806 "2016-04-28T17:35:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Napoleonite](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Napoleonite](https://forums.unrealengine.com/u/Napoleonite)\
**Post date:** [April 28, 2016, 5:35pm UTC](https://forums.unrealengine.com/t/widgetstyle-undeclared-identifier/355806/1 "2016-04-28T17:35:47Z")

</div>

I’m trying to make a TextBlock Widget with a predefined style. This code works for a button but a TextBlock does not have a WidgetStyle? I can create a SlateWidgetStyleAsset in the UE4 editor so it would only make sense it also has a WidgetStyle right? I got it to work for a Button but I can’t get it to work for the TextBlock.

VS output Error: **…\TextBlock\_Styled.cpp(15): error C2065: ‘WidgetStyle’: undeclared identifier**

I enabled this line in the build-file: _PrivateDependencyModuleNames.AddRange(new string[] { “Slate”, “SlateCore” });_

And the documentation for TextBlock is awesome: [TextBlock | Unreal Engine Documentation](https://docs.unrealengine.com/latest/INT/API/Runtime/Slate/Widgets/Text/SInlineEditableTextBlock/TextBlock/index.html) (1 whole line of text).

```
#include "Runtime/UMG/Public/UMG.h"
#include "Components/TextBlock.h"
#include "TextBlock_Styled.generated.h"

/**
 * 
 */
UCLASS(meta = (DisplayName = "TextBlock Styled"))
class FPS2_API UTextBlock_Styled : public UTextBlock
{
	GENERATED_BODY()

	UTextBlock_Styled();
	
#if WITH_EDITOR
	virtual const FText GetPaletteCategory() override;
#endif
};

#include "FPS2.h"
#include "TextBlock_Styled.h"

#define LOCTEXT_NAMESPACE "UMG"

UTextBlock_Styled::UTextBlock_Styled()
{
	static ConstructorHelpers::FObjectFinder<USlateWidgetStyleAsset> CustomStyle(TEXT("/Game/GUI/Styles/TextBlock_SWS"));

	STextBlock::FArguments TextBlockDefaults;
	TextBlockDefaults.TextStyle(CustomStyle.Object);
	WidgetStyle = *TextBlockDefaults._TextStyle; // <<<<<<<<<<<<<< ERROR here.
}

#if WITH_EDITOR
const FText UTextBlock_Styled::GetPaletteCategory()
{
	return LOCTEXT("", "Custom");
}
#endif

#undef LOCTEXT_NAMESPACE
```

---

<div class="post-metadata">

**Author:** ![itandfeel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itandfeel](https://forums.unrealengine.com/u/itandfeel)\
**Post date:** [April 13, 2018, 11:49am UTC](https://forums.unrealengine.com/t/widgetstyle-undeclared-identifier/355806/2 "2018-04-13T11:49:12Z")

</div>

This question is very old, but we had same issue.

We Fixed it with:  
#include “Runtime/SlateCore/Public/Styling/WidgetStyle.h”
