[Compile Fail]Extend UButton

I want to extend UButton class but the compiler gives failure. The code is below. It has been generated by using the ue editor already.

Additional Info:

  • I have added “UMG” to PublicDependencyModuleNames.

Code:

#pragma once

#include "Components/Button.h"
#include "MyButton.generated.h"

UCLASS()
class HEROMASTERS_API UMyButton : public UButton
{
	GENERATED_BODY()
	
};

Compiler Error:

1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(23): error C2504: 'UContentWidget': base class undefined
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(24): error C3646: 'Super': unknown override specifier
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(110): error C2061: syntax error: identifier 'UPanelSlot'
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(111): error C2061: syntax error: identifier 'UPanelSlot'
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(24): error C3668: 'UButton::_getUObject': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(90): error C3668: 'UButton::SynchronizeProperties': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(94): error C3668: 'UButton::ReleaseSlateResources': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(98): error C3668: 'UButton::PostLoad': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(102): error C3668: 'UButton::GetEditorIcon': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(103): error C3668: 'UButton::GetPaletteCategory': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(109): error C3668: 'UButton::GetSlotClass': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(110): error C3668: 'UButton::OnSlotAdded': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(111): error C3668: 'UButton::OnSlotRemoved': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(122): error C3668: 'UButton::RebuildWidget': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(24): error C2440: 'return': cannot convert from 'UButton *' to 'UObject *'
1>  C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(24): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\erayt\documents\unreal projects\heromasters\source\heromasters\MyButton.h(14): error C2440: 'return': cannot convert from 'UMyButton *' to 'UObject *'
1>  c:\users\erayt\documents\unreal projects\heromasters\source\heromasters\MyButton.h(14): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(23): error C2504: 'UContentWidget': base class undefined
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(24): error C3646: 'Super': unknown override specifier
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(110): error C2061: syntax error: identifier 'UPanelSlot'
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(111): error C2061: syntax error: identifier 'UPanelSlot'
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(24): error C3668: 'UButton::_getUObject': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(90): error C3668: 'UButton::SynchronizeProperties': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(94): error C3668: 'UButton::ReleaseSlateResources': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(98): error C3668: 'UButton::PostLoad': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(102): error C3668: 'UButton::GetEditorIcon': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(103): error C3668: 'UButton::GetPaletteCategory': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(109): error C3668: 'UButton::GetSlotClass': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(110): error C3668: 'UButton::OnSlotAdded': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(111): error C3668: 'UButton::OnSlotRemoved': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(122): error C3668: 'UButton::RebuildWidget': method with override specifier 'override' did not override any base class methods
1>C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(24): error C2440: 'return': cannot convert from 'UButton *' to 'UObject *'
1>  C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\UMG\Public\Components/Button.h(24): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Users\ErayT\Documents\Unreal Projects\HeroMasters\Source\HeroMasters\MyButton.h(14): error C2440: 'return': cannot convert from 'UMyButton *' to 'UObject *'
1>  C:\Users\ErayT\Documents\Unreal Projects\HeroMasters\Source\HeroMasters\MyButton.h(14): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

I do not know how and why but I found an article related with UserWidgets and it says that the following header files must be included in the project header file(ProjectName.h).

#include "Runtime/UMG/Public/UMG.h"
#include "Runtime/UMG/Public/UMGStyle.h"
#include "Runtime/UMG/Public/Slate/SObjectWidget.h"
#include "Runtime/UMG/Public/IUMGModule.h"
#include "Runtime/UMG/Public/Blueprint/UserWidget.h"

I think you should include

#include "Widgets/SCompoundWidget.h"

in the header file.

D.