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"

Unable to Set Widget Variable when Created in C++

Hello! I'm working on creating a menu with a combination of UMG and C++.

The visuals will be made with UMG Blueprints, but want to reference them in C++ so I can hook up their functionality there.

I first created a C++ class and added a Widget Switcher reference to it. With UPROPERTY, I was able to expose this in Blueprints:

 #pragma once
 #include "CoreMinimal.h"
 #include "Blueprint/UserWidget.h"
 #include "WidgetSwitcher.h"
 #include "TestWidget.generated.h"
 class GCMACPREVIEW_API UTestWidget : public UUserWidget
     virtual void NativeConstruct() override;
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Parent Widgets")
     UWidgetSwitcher* MenuWidgetSwitcher = nullptr;

I then created a Blueprint off this class (tried directly creating from C++ class and reparenting when created from UserWidget) and I could see my reference I had created.

Reference Switcher

I then created a variable in the Blueprints graph called "BP Switcher" and made it instance editable:

BP Widget Switcher

With these created, I added a UMG Widget Switcher called "WidgetSwitcher_180". This is listed as an option to reference by my variables, but only the BP-created value can be set. The C++ variable just remains blank when I select the option:

alt text

The main reason I cannot use the "meta=(BindWidget)" option is because I am setting this value when it is the child of another widget (see photo below):

Goal Widget Hierarchy

Is there some other setting I need to set so I can reference my Blueprint Widget in C++?

Product Version: UE 4.22
more ▼

asked May 28 '19 at 11:26 PM in Using UE4

avatar image

1 3 3

avatar image Nebula Games Inc May 29 '19 at 01:18 PM

When you use the specifier "Blueprintable" do you create a blueprint class based off the C++ class by right clicking the content browser and asking to create a new BP class then typing in the name of your C++ class? (I see you tried re-parenting, but that is not the ideal way to create the blueprint).

avatar image philAtWork May 29 '19 at 05:16 PM

I created a blank project and tried creating the Blueprint class directly from by C++ class, but it has the same result unfortunately.

avatar image Nebula Games Inc May 29 '19 at 01:22 PM

Also, can you give better screen shots? It is hard to tell where you are attempting to set this variable. And from what menu/details panel.

avatar image philAtWork May 29 '19 at 05:19 PM

Sure! I updated the question and images and created a blank project to help focus on the issue I'm having.

avatar image philAtWork Jun 05 '19 at 04:28 PM


Unfortunately, I still cannot resolve this issue. :( As a workaround, I need to create a dummy BP, create duplicate variables in BP mirroring the C++ variables, and set the BP variables to the C++ variables in the Construct function. This dummy BP is then inherited by other UMG's where I can set my BP variable references.

Though this works now, if I need to track 100 variables in C++, that would mean I would have to create an extra 100 variables in BP and set them individually to each C++ variable, which would be very cumbersome.

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

1 answer: sort voted first

Hi, look here, this is going to help you. I developed them recently for 4.22. the corrections are in the answer. I leave the link:

link text

more ▼

answered May 29 '19 at 02:07 PM

avatar image

93 2 8 9

avatar image philAtWork May 29 '19 at 05:16 PM

Thank you for your response. Unfortunately, I cannot use BindWidget to reference the value because it is referencing a widget in the parent widget.

I updated my question with a sample project to give more information.

(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