Why is "UUserWidget is not a type name" when I try to declare the variable?

Every where Ive looked has told me to declare it like so:

UUserWidget* MyMainMenu;

But when I do I get an Intellisense error stating “UUserWidget is not a type name”

If I declare it like so:

class UUserWidget MyMainMenu;

It suddenly becomes fine with UUserWidget, but instead flags MyMainMenu with “incomplete type is not allowed”

How do I properly declare a UUserWidget ?

Hi Erdrik,

At first I though it was a simple "did you include UserWidget.h but it’s not only that.

the fix is quick though, just add UMG to the build dependencies and add a few header to your project.

Here’s the tutorial that will give you the correct ones, just tried it and got it to work withing 2 minutes

Enjoy

  • Marc

BTW, you just need step 1 and 2, and then #include “Blueprint/UserWidget.h” where you want to use UUserWidget* myWidget;

I already have both the dependency entries and the includes, and tried to follow that tutorial.

I can not get to step four.

I did just notice another error tho:

#include "Blueprint/UserWidget.h"

is throwing: cannot open source file “Blueprint/UserWidget.h”

include the full path my friend: #include “Runtime/UMG/Public/Blueprint/UserWidget.h”

That is the full path for the include in ‘MyProjectName.h’(which I have in place already)

I was refering to the include in the created widget header.(InventoryWidget in the tutorial IIRC)

In the tutorial InventoryWidget’s include reads:

#include "Blueprint/UserWidget.h"

I Tried your suggestion anyway, and all it did was move the error to:

#include "InventoryWidget.generated.h"

You would never need to copy paste this one (InventoryWidget.generated.h)
Its either automatically added for you if that’s the name of your class, or you don’t need it.

Bit of a late reply but I ran into this problem… Needed to add UMG, Slate and SlateCore to the public dependencies in the build file, check out: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums