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. :slight_smile:

(I can provide pictures of the blueprints if needed)

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.

Thanks for your answer!

So I replicated the issue with just a variable:

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:

248453-hud1.png

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.

The print string displays the correct value.

After this I try to print the variable in the first blueprint.

248455-bp3.png

And for some reason it doesn’t work here.

(note that the engine version is 4.18.3)

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.

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.

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

Have a look at this:

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.

Thank you for your answers :slight_smile:

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.

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.

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):

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!

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:

Video:

https://drive.google.com/open?id=16f0aveOi7qRhtznOruxerjHwaSbCyWpn

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

https://drive.google.com/open?id=1k2j_Yd4YtX552q-w6LnzlGzxvImM1ews

Do note that this if far from production ready :wink:

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!

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

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