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

**URL:** <https://forums.unrealengine.com/t/why-is-uuserwidget-is-not-a-type-name-when-i-try-to-declare-the-variable/312157>\
**Category:** UI\
**Tags:** type, unreal-engine, Widget, question, CPP\
**Created:** [March 22, 2015, 6:39pm UTC](https://forums.unrealengine.com/t/why-is-uuserwidget-is-not-a-type-name-when-i-try-to-declare-the-variable/312157 "2015-03-22T18:39:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erdrik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Erdrik](https://forums.unrealengine.com/u/Erdrik)\
**Post date:** [March 22, 2015, 6:39pm UTC](https://forums.unrealengine.com/t/why-is-uuserwidget-is-not-a-type-name-when-i-try-to-declare-the-variable/312157/1 "2015-03-22T18:39:31Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![MarcAndreG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MarcAndreG](https://forums.unrealengine.com/u/MarcAndreG)\
**Post date:** [March 22, 2015, 7:26pm UTC](https://forums.unrealengine.com/t/why-is-uuserwidget-is-not-a-type-name-when-i-try-to-declare-the-variable/312157/2 "2015-03-22T19:26:37Z")

</div>

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

> **[\[Tutorial\] Extend UUserWidget for UMG](https://forums.unrealengine.com/showthread.php?38097-Tutorial-Extend-UUserWidget-for-UMG)**
>
> So i just started with UMG and after a week of messing around with it. I wanted to extend the Widget Blueprint, i got some great help from Nick Darnell so thanks again. Disclaimer This was done in UE 4.4.2 as UMG is experimental and may change...

---

<div class="post-metadata">

**Author:** ![MarcAndreG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MarcAndreG](https://forums.unrealengine.com/u/MarcAndreG)\
**Post date:** [March 22, 2015, 7:32pm UTC](https://forums.unrealengine.com/t/why-is-uuserwidget-is-not-a-type-name-when-i-try-to-declare-the-variable/312157/3 "2015-03-22T19:32:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Erdrik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Erdrik](https://forums.unrealengine.com/u/Erdrik)\
**Post date:** [March 22, 2015, 9:28pm UTC](https://forums.unrealengine.com/t/why-is-uuserwidget-is-not-a-type-name-when-i-try-to-declare-the-variable/312157/4 "2015-03-22T21:28:46Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![ZkarmaKun](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zkarmakun/32/1194545_2.png) [@ZkarmaKun](https://forums.unrealengine.com/u/ZkarmaKun)\
**Post date:** [March 22, 2015, 11:02pm UTC](https://forums.unrealengine.com/t/why-is-uuserwidget-is-not-a-type-name-when-i-try-to-declare-the-variable/312157/5 "2015-03-22T23:02:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Erdrik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Erdrik](https://forums.unrealengine.com/u/Erdrik)\
**Post date:** [March 23, 2015, 5:06am UTC](https://forums.unrealengine.com/t/why-is-uuserwidget-is-not-a-type-name-when-i-try-to-declare-the-variable/312157/6 "2015-03-23T05:06:43Z")

</div>

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"

```

---

<div class="post-metadata">

**Author:** ![MarcAndreG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MarcAndreG](https://forums.unrealengine.com/u/MarcAndreG)\
**Post date:** [March 23, 2015, 11:08am UTC](https://forums.unrealengine.com/t/why-is-uuserwidget-is-not-a-type-name-when-i-try-to-declare-the-variable/312157/7 "2015-03-23T11:08:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Daganar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Daganar](https://forums.unrealengine.com/u/Daganar)\
**Post date:** [March 20, 2017, 1:40am UTC](https://forums.unrealengine.com/t/why-is-uuserwidget-is-not-a-type-name-when-i-try-to-declare-the-variable/312157/8 "2017-03-20T01:40:46Z")

</div>

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](https://wiki.unrealengine.com/UMG,_Referencing_UMG_Widgets_in_Code)
