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"

Setting Up Widget Elements in Constructor of UUserWidget

I'd like to make a constructor for a UUserWidget in which I add some widget elements like a vertical box to the widget tree that can be edited in the UMG view but still called from C++, as you may add a component to an actor through C++ in the constructor and edit it in the viewport. This seems like the most natural way to work with UMG from C++, but I'm stumbling all over it! Is this possible? How would I do it?

Thanks!

Product Version: UE 4.14
Tags:
more ▼

asked Mar 01 '17 at 05:48 PM in C++ Programming

avatar image

calembendell
447 35 37 67

avatar image Kamarov Jun 10 '17 at 10:15 PM
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I have an answer from Unreal!
Special thanks to Cody Albert.

"it sounds like you're looking for BindWidget, a property metatag that lets you define a UMG widget property in C++ and automatically bind to the instanced created with the same name in the UMG editor. We don't have much documentation for the tag just yet, but I'll walk you through it.

On your C++ class which inherits UUserWidget, define UProperties for any widgets you want as follows:

  UPROPERTY(meta = (BindWidget)) 
  UPanelWidget* MyPanel;

Then, when you create a UUserWidget using your derived class in the UMG editor, you'll create a panel and name it MyPanel, and we'll automatically bind this c++ property to the created widget behind the scenes. Note that you'll see a compile error if no widget MyPanel is found or if it's a different widget class. Alternatively, if you don't want to see a compile error and want the implementation of the property to be optional, you can declare it as follows:

  UPROPERTY(meta = (BindWidgetOptional)) 
  UPanelWidget* MyOptionalPanel;
  

Best,

Cody"

more ▼

answered Mar 01 '18 at 07:02 PM

avatar image

calembendell
447 35 37 67

avatar image Marquisd May 22 '19 at 04:16 AM

Wow. Thanks for sharing this. Exactly what I needed.

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

I've not yet found a way to do this, so far everything seems to point at can't be done, but nothing with a staff member confirming that's the case and whether it's intended. Here's another thread on the same question. https://answers.unrealengine.com/questions/521224/request-improve-inheritance-in-userwidget.html

more ▼

answered May 06 '17 at 10:11 PM

avatar image

skyphyr
169 3 62 14

avatar image calembendell Mar 01 '18 at 07:02 PM

I have posted the answer now :-)

(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