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"

AddViewportWidgetContent(SNew gives error "'MakeTDecl': no matching overloaded function found"

I have minimal test project for a menu from the forum where the new class SMainMenu is derived from SCompoundWidget.

This is the header of the class:

 #pragma once

 #include "Slate.h"
 class SMainMenu : public SCompoundWidget
     // Constructor for slate widgets
     void Construct(const  FArguments& InArgs);
     //Start  button callback 
     FReply StartBtnClicked();
     //Function to Create Menu 
     TSharedRef<SWidget> MyMenu();

My HUD class has a member variable MyUIWidget. In my HUD cpp I use it like this:

 MyUIWidget = SNew(SMainMenu); 
 GEngine->GameViewport->AddViewportWidgetContent(SNew(MyUIWidget.ToSharedRef() ) );

This gives me the error:

 error C2672: 'MakeTDecl': no matching overloaded function found
 error C2974: 'MakeTDecl': invalid template argument for 'WidgetType', type expected

If I use instead


It seems to work. I get a GUI. Not really tested for further problems.

Now my questions:

  1. Is the second version without error the correct version and the API documentation is wrong? (I don't think so, to be honest)

  2. If the first version - the one with the error - is the correct one, what is the meaning of that error? How do I fix this? And why?

Product Version: UE 4.17
more ▼

asked Sep 07 '17 at 07:48 PM in C++ Programming

avatar image

210 9 14 20

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

1 answer: sort voted first

I found my answer in the "Strategy Game", the sample project we get for free.

 GEngine->GameViewport->AddViewportWidgetContent(SNew(SWeakWidget).PossiblyNullContent(MyUIWidget.ToSharedRef() ) );
more ▼

answered Sep 08 '17 at 01:09 PM

avatar image

210 9 14 20

(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