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"

UMG: How to create default buttons

I'm trying to extend UUserWidget in order to create an in game menu that I can manipulate with both C++ and blueprint. I've got my base class compiling, but I'm attempting to add a series of buttons to my widget that will auto populate when I create a new blueprint, akin to a default sub object in an object blueprint. As such, I am working in the constructor, trying to create the button widgets and see them in the widget blueprint editor.

I have tried CreateDefaultSubobject, but that doesn't add them to the Canvas.

I have tried GetSlotNames(), but it causes an access violation.

I have tried to access the Canvas directly, but can't find where it has been added, as it is not referenced in either UUserWidget() or UWidget(), and if I do GetWidgetFromName(FName(TEXT("Canvas Panel"))), I get an access violation.

Supposedly I can call AddChild, but UUserWidget has no such function, nor can I find one. Does anyone know how to solve this issue?

Product Version: UE 4.9
more ▼

asked Oct 28 '15 at 08:46 PM in C++ Programming

avatar image

51 8 10 15

avatar image cageman Oct 28 '15 at 08:56 PM

The way i combine blueprints and C++ for umg is by creating widgets derived from UWidget in C++. Afterwards i combine them in blueprints, which is much easier. I would advise you to do the same thing. You can build slate style widgets this way and expose them to blueprints. You just have to implement the method RebuildWidget(), in the constructor of the class you can initialize some data, but the widget itself has to be build in the RebuildWidget method. Using this method i build things like serverlists, custom comboboxes etc. You can easily add a few default widgets the RebuildWidget methods if you would like to do that.

avatar image Tiskahar Oct 29 '15 at 04:38 PM

Interesting. I'll have to do my homework on Slate, then. Still not sure what the difference between UWidget and SWidget, but I'll look into it. Thank you.

avatar image SalahAdDin May 31 '19 at 03:59 PM

How can we add the buttons to a UUserWidget c++ class?

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

0 answers: sort voted first
Be the first one to answer this question
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