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"

Trying to add multiple instances of the same widget with different data to a scrollbox

So as the title says I've been trying to add different versions of the same widget to a scrollbox.

I did this with creating the same widget multiple times with a loop and adding it as a child each time with different data. This works fine.

The problem: Each widget has a button, with this button I want to add the content of that specific widget to an array that is in a different blueprint, but for some reason, I can't. I add the data to the array in the widget blueprint but when I try to access the array elsewhere there is nothing in it.

I also tried it with simple variables but it seems like I can't get any data out of these widgets to other blueprints.

Any reason why this happens? And what could be the solution?

Any help would be greatly appreciated. :)

(I can provide pictures of the blueprints if needed)

Product Version: UE 4.18
more ▼

asked Jul 24 '18 at 08:52 PM in Blueprint Scripting

avatar image

1 1 2 2

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

1 answer: sort voted first

What you describe should work fine.

I add the data to the array in the widget blueprint but when I try to access the array elsewhere there is nothing in it.

Can you show how you try to access the widgets' data arrays elsewhere? Essentially the bit you expect to work.

more ▼

answered Jul 24 '18 at 10:47 PM

avatar image

15.3k 77 26 64

avatar image Geri1220 Jul 25 '18 at 10:41 AM

Thanks for your answer!

So I replicated the issue with just a variable:

alt text

In this widget when I press a button I create the other widget give it a random value and add it to a scrollbox.

At the end I get something like this: alt text

After this in the second widget on a button press, I try to change a variables value to the current widget's value. (for example clicking the button on the first purple box should change the value to 7) This variable is declared in the first widget blueprint. alt text The print string displays the correct value.

After this I try to print the variable in the first blueprint. alt text And for some reason it doesn't work here.

(note that the engine version is 4.18.3)

bp1.png (108.0 kB)
hud1.png (66.9 kB)
bp2.png (77.6 kB)
bp3.png (36.8 kB)
avatar image Everynone Jul 25 '18 at 10:58 AM

I'm a bit confused. Not sure what your intentions here are but in the first picture, you're extracting just the canvas from the TestWidget2 and move it to the scrollbox, leaving an orphaned and canvasless TestWidget2 behind...

Perhaps you want to add the entire widget as content to the scrollbox instead.

avatar image Geri1220 Jul 25 '18 at 11:23 AM

I tried it but I still have the problem.

The main problem is I can't get any data out of the widgets that I create. Maybe the reason for it is because I create the same widget multiple times.

It is possible that I am doing something fundamentally wrong because I am a beginner.

avatar image Everynone Jul 25 '18 at 11:37 AM

Each widget you create is a separate instance and holds its own data.

Have a look at this:

alt text

I create a W_Scrollbox widget and add 10 children to the scrollbox inside, each with a randomised Int. I then pick one at random and read the data inside. This works fine.

Perhaps you'd like to describe what you're trying to create, I might be able to push you gently in the right direction. I mean the high level stuff - what the end user is supposed to with it.

capture.png (285.2 kB)
avatar image Geri1220 Jul 25 '18 at 12:04 PM

Thank you for your answers :)

I will try your solution when I get home, and tell you if it helped.

By the way the end product supposed to be a list of randomly generated "people", and the user would be able to put selected "people" into a different list. Like there are avaible workes and you can hire them.

avatar image Everynone Jul 26 '18 at 09:56 AM

Makes sense.

I'd then have a JobBoard widget with 1 list containing Persons widget and additional jobs lists (scrollboxes, right, ideally separate wigets) waiting to be populated.

AddChild (existing Person widget from JobBoard) to a Persons List should automatically reparent the Person from one list to another. This way you do not need to worry about making copies of the person (unless it is desired, of course.

Let me know if you're having issues with setting this up.

avatar image Geri1220 Jul 30 '18 at 01:32 PM

Sorry for the late reply I could only try what you suggested today.

I replicated your blueprint and it works perfectly (thank you so much for that!) but the problem is that I can only get data out of the child by giving the index of it. How do I get the data out of the child with a button?

I tried it like this(this is the child's bp): alt text but for some reason, it doesn't work, it removes the widget from the current scrollbox but doesn't add it to the other one.

Any reason why this happens?

And thanks again for the help so far!

bp.png (96.1 kB)
avatar image Everynone Jul 30 '18 at 02:38 PM

One way to do it is to have a child call an Event Dispatcher registered with a parent. I've quickly put this together to demonstrate the idea:



The 2 widgets are attached, feel free to take it apart:


Do note that this if far from production ready ;)

avatar image Geri1220 Jul 30 '18 at 03:20 PM

Thank you so much for doing this that is almost exactly what I wanted to make. :)

Now I'm updating my engine but after that I'll try your blueprints.

avatar image Everynone Jul 30 '18 at 03:25 PM

No problem, let me know if there's anything unclear.

The list selection by double clicking is hard-coded. I wouldn't do it like this normally. A much more sensible approach (especially with multiple lists) is to have them as separate widgets, with their own dispatchers and use the main JobBoard as a communication hub.

Anyway, this is a stub of something, hopefully it's useful.

Good luck!

(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