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"

How to add a "Widget" in a extended UUserWidget.

After extending a UUserWidget class and set it to the parent class in the WidgetBlueprint. How can i add a new member to that Widget as i whould a component for a actor? alt text

Product Version: Not Selected
item.png (24.3 kB)
more ▼

asked Nov 10 '14 at 01:03 AM in C++ Programming

avatar image

508 43 44 73

avatar image Ben.Driehuis Nov 10 '14 at 04:53 AM

What are you trying to add exactly? Are you trying to force a slate widget to always be on the root widget on your UserWidget?

If so why? The whole reason to use UMG is to allow layout to be done easily, locking in the root widget seems to be a big restriction.

Can you provide a bit more information so I can understand what you are trying to do here, I've been playing a bit with UMG and Slate in C++ lately.

avatar image WCode Nov 10 '14 at 01:15 PM

Basicly i want to make the variabels/ Widgets in C++. And when i go into the editor i want thos to be visible and available for edit. By default it has Root > Canvas Panel

So i whould like to have e.g: Root > Canvas > Border

The resson for this is to have the mebers available in the extended user widget and available in code.

EDIT: Also this is on a related note with code and UMG/ User Widget. https://forums.unrealengine.com/showthread.php?51649-Binding-delegates-in-a-user-widget

avatar image Ben.Driehuis Nov 10 '14 at 10:04 PM

See if the answer helps, as for the forum question, I posted a reply there on how to fix the crash you are getting.

Edit: In case they dont approve fast enough, the trick for the crash is to always remove the delegate first, I do this all the time and it will just do nothing if it isnt bound. I saw epic were doing it in examples. So go RemoveDynamic first

avatar image WCode Nov 11 '14 at 01:48 PM

Great that worked like a charm :D Am testing the answer aprichiate the help.


avatar image Ben.Driehuis Nov 11 '14 at 09:55 PM

No worries at all, post any questions re the answer below it :)

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

1 answer: sort voted first

I am not sure you can really easily force widgets onto the scene without changing engine code.

Alternatively you could though manually add the widgets you want in UMG and then catch them in code and do things with them.

I have started doing this in places in our code now. I wrote a menu slate widget (and UMG version) to handle lots of common stuff we needed and my extended UserWdiget class searches for the first widget with this type and binds to it.

I do this in RebuildWidget, after the super.

  TSharedRef<SWidget> USubmergedOptionsMenuUserWidget::RebuildWidget()
      TSharedRef<SWidget> OurWidget = Super::RebuildWidget();
      for (UWidget* Widget : Components)
          if (Widget->IsA(USubmergedMenuWidget::StaticClass()))
              //found it now do whatever you need to it, store the pointer etc
      return OurWidget;

I do this so that we can put our menu widget in any layout choice we want without me having to change code. But once they added it I then can change anything else I want. I progamatically add the relevant menu items, what to do on the click op options, what the keyboard/controller/touch input mean, handle the localization etc.

This approach might help you here, sure you have to manually add the widgets you want, but since you probably only have to do this one or twice, its usually not too bad a headache.

Let me know if this is helpful at all and if you want any more information about what I have done.

more ▼

answered Nov 10 '14 at 10:03 PM

avatar image

496 18 27 142

avatar image Ben.Driehuis Nov 11 '14 at 09:55 PM

Obviously if you have many items of the same type you can match by name, I do that in places too.

avatar image WCode Nov 20 '14 at 06:42 AM

Sorry for late reply sometimes the schedual get the better of me. This was very helpful so thank you very much i decided i was over complicating stuff a bit. But none the less this is going to be very nice to know about down the line as well. Cheers!

avatar image dbrizov May 14 '17 at 11:37 AM

The API has been changed a little. You can no longer iterate through the Components this way. You can get the widgets by calling WidgetTree->GetAllWidgets(TArray& OutWidgets). You also must make sure that you added the private dependencies for Slate UI, otherwise the WidgetTree is inaccessible. Just uncomment the PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); in the [ProjectName].Build.cs

(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