x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 ?

Product Version: Not Selected
Tags:
more ▼

asked Mar 22 '15 at 06:39 PM in C++ Programming

avatar image

Erdrik
408 47 52 73

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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

https://forums.unrealengine.com/showthread.php?38097-Tutorial-Extend-UUserWidget-for-UMG

more ▼

answered Mar 22 '15 at 07:26 PM

avatar image

MarcAndreG
710 27 12 40

avatar image MarcAndreG Mar 22 '15 at 07:32 PM

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

avatar image Erdrik Mar 22 '15 at 09:28 PM

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"

avatar image ZkarmaKun Mar 22 '15 at 11:02 PM

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

avatar image Erdrik Mar 23 '15 at 05:06 AM

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"



avatar image MarcAndreG Mar 23 '15 at 11:08 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

more ▼

answered Mar 20 '17 at 01:40 AM

avatar image

Daganar
1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question