Cannot access header file

I am new to UE4. I am learning it by following this site’s tutorial. There is a tutorial about timer .
At the first I use UTextRenderComponent declare a variable, but it says the UTextRenderComponent not defined.
So I searched on Internet and I know I must #include "Runtime/Engine/Classes/Components/TextRenderComponent.h" , then it’s ok. But when I called UTextRenderComponent member function SetHorizontalAlignment, it didn’t give me a code suggestion and show an error.

When I hovered on it. it showed:

void UTextRenderComponent::SetHorizontalAlignment(EHorizTextAligment Value)
function "UTextRenderComponent::SetHorizontalAlignment"(declared in line:127, file:"F:\Epic Games\UE_4.20\Engine\Source\Runtime\Engine\Private\Components\TextRenderComponent.h") cannot access.

However, I press Ctrl + left click, I can open that header file.Although it can be complied successfully, it makes me feel bad without code suggestion. Could anyone please help me find out the problem?

try :
#include “Components/TextRenderComponent.h” since this are include folders. basicly components might be internaly a module/dll and thats it basefolder. well its the structure of the ue4 engine.

I have tried the solution you metioned, but it didn’t work.

So I just created an Empty project where I used the #include "Components/TextRenderComponent.h" and then I declared the comp as you did and everything went as intended. There is an issue with the engine and precompiled header tho, be sure that until it’s fixed in 4.20.3 the Intermediate/Build!Platform/UE4Editor/Inc/ProjectName is part of your includes in your solution

what i forget to say.
u might edit ur Projectname.build.cs file.
So it might not work, because u didnt include “UMG” in it.

So what does it do. Its including a module into ur project(badicly similar to a dll in ue4). So u have to set the correct the corrent path(with include) and also to include the dll/module in the build.cs or it wont work.

for my actual project it is like
:

Blockquote
using UnrealBuildTool;

public class Projectname : ModuleRules
{
public Projectname (ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

    PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG" , "RHI" , "GameplayTasks" });
    PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

So for example (what i do when i add new functionallity from ue4 engine).

– I open up the .h where the function i need is defined.
– then i take a look at the path. in my case
“…\UnrealEngine\UE_4.19\Engine\Source\Runtime\UMG\Public\Components\WidgetComponent.h”
–(alternativly u can google the API/funcion and then scroll down. there u find the needed module and path of the header file “http://api.unrealengine.com/INT/API/Runtime/Engine/Components/UTextRenderComponent/”)
– the important part is “UMG\Public\Components\WidgetComponent.h”

– the used module by the header is UMG here.
– so i ensure UMG is added to the projectname.build.cs
– when its add. “…UMG\Public” is an include folder in ur project(similar to a normal c++ project)
– so to include the header to my own header/project i use
– "#include “Components\WidgetComponent.h” "

I hope this helps. Google / search for build.cs etc if u want to get deeper into it.
Also it always help

I think it because of the member in this class is private, so it cannot be used by VS default Intellisense ?