1
\$\begingroup\$

I have a UserWidget object with a ListView in it.

How do I add objects add and custom data to them, such as names?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

First read the tooltip info:

enter image description here

To add an item with custom properties, you need the following parts:

  • List View
  • Data entry object
  • Presentation widget

The idea behind this setup is most likely to keep data and presentation separated.

Data entry object

The data entry object's purpose is only to store data. Create it as a Blueprint class that inherits from Object.

When we add new items to the ListView, we create a new data entry object:

enter image description here

Important: To make FruitName visible, that property needs to have the following settings enabled in the data entry object (BP_Fruit_Data_Entry):

enter image description here

Presentation widget

This is what we tell our ListView that we want to display. We do it here:

enter image description here

Important: In order for our Presentation widget (W_Fruit_Presentation_Widget) to be shown here, it needs to:

  1. Inherit from UserWidget
  2. Implement the User Object List Entry interface: enter image description here

Presenting the data

When you have added a new data entry object to your list, it will automatically create a new presentation widget of the class that you defined.

When it does that, it will call On List Item Object Set. This is where you take the data and put make it presentable:

enter image description here

Here's an overview on how it works:

enter image description here

I created an example project a simple setup here: https://github.com/01F0/umg-listview-example

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for this! I don't know how I would have figured out that I need to implement that interface on my own! \$\endgroup\$
    – Ben Mora
    Commented Mar 18, 2022 at 15:30
  • \$\begingroup\$ @BenMora Happy to help! :) I just want to add that a scrollbox + vertical view + custom widget could be enough in most cases.. forums.unrealengine.com/t/… \$\endgroup\$
    – 01F0
    Commented Mar 19, 2022 at 7:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .