UUserWidget incomplete type is not allowed

I have been following a tutorial about how to make a UMG widget into code.

A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums.

I have run into many problems when trying to use this code. First, I have an incomplete type error on my UUserWidget. Second, this incomplete type error cascades down throughout my code. I have tried to find any workarounds but I have not found any. I need to find a workaround for the UUserWidget problem.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Runtime/UMG/Public/Blueprint/UserWidget.h"
#include "MainMenuBP.generated.h"

/**
 * 
 */
UCLASS()
class MAINMENUCODE_API UMainMenuBP : public UUserWidget
{
	GENERATED_BODY()

public:
	UMainMenuBP(const FObjectInitializer& ObjectInitializer);

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = MainMenu)
	TSubclassOf<UUserWidget> WidgetTemplate;

	UPROPERTY()
	UUserWidget* WidgetInstance;
};

The error is found in the first line of the class.

class MAINMENUCODE_API UMainMenuBP : public UUserWidget

Try this:

#pragma once
 
#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"
#include "MainMenuBP.generated.h"
 
 /**
  */
 UCLASS()
 class UMainMenuBP : public UUserWidget
 {
     GENERATED_BODY()
 
 public:
 
     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = MainMenu)
     TSubclassOf<UUserWidget> WidgetTemplate;
 
     UPROPERTY()
     UUserWidget* WidgetInstance;
 };

“IncompleteType” errors mean you’re forward declaring a class and the compiler needs the class’s full definition. In this case, a header you’re including is likely forward declaring a class.

I had a similar problem with UUserWidget and just added all of these includes:

#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"

and it fixed the problem.

I tried the solutions presented, but the error persists. Could it be that I’m using 4.6.1? Has UUserWidget gone private?

Can you update your question with your new header file and the exact errors you’re getting?

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#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"
#include "MainMenuBP.generated.h"

/**
 * 
 */
UCLASS()
class MAINMENUCODE_API UMainMenuBP : public UUserWidget
{
public:
	GENERATED_BODY()

	UMainMenuBP(const FObjectInitializer& ObjectInitializer);

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = MainMenu)
	TSubclassOf<UUserWidget> WidgetTemplate;

	UPROPERTY()
	UUserWidget* WidgetInstance;
};

Errors on this page.

class UUserWidget
Error: incomplete type not allowed

found on line:
class MAINMENUCODE_API UMainMenuBP : public UUserWidget
under
UUserWidget

Thanks again for the help.

I fixed it. The answer was that initially when I created the class I used something other than UserWidget to automatically create the class. I guess when the class got automatically created that more was going on behind the scenes than anticipated. Once I created a new class with a UserWidget as the class then all the problems disappeared. Once again, I would like to thank you guys for the quick response and thank you for the help.