How to use SetText with List View?

So, essentially, the list view controls the whole lot, it’s fully responsible for creating and setting its objects’ data. Fair enough. As soon as I find some time, I’ll take it for a spin for the sake of getting it to work so I can tick it off my mental list of things that I think are broken.

I’ll edit my rant post, too. Perhaps @Raisonbran648 can accept this answer instead. Thanks again for looking into this!

Hello,
I had the same issues as you all and I think I found a way to do that kinda properly.

First, the object you have to add to ListView (with AddItem) is NOT a Widget, it’s like a ‘Data Object’.
Second, the objet type set as ‘Entry Widget Class’ should inherit ‘UserOBJECTListEntry’.
Then, in this object, you can implement ‘Event On List Item Object Set’, that will give you the ‘Data Object’ linked to this Widget.
Coming from this, you can implement the SetText when needed to update the widget as the Item evolves :slight_smile:

Hope this helps,

That actually sounds promising, I’ll give it a go!

This is what appens in my class set as ‘Entry Widget Class’ (i know the Event Tick is a bit overkill, but after an hour or so trying to figure out wtf is going on … :D)
This explains also how you can actually fill the function ‘GetListItemObject’ i guess

No problem, I had the same problem too and I always got on this post … so I guess it would be the time to answer here.
I hope i dont lead you in a bad direction, that it’s the way to do … but as it seems as noone made it work … it’ll do it :slight_smile:

First, the object you have to add to
ListView (with AddItem) is NOT a
Widget, it’s like a ‘Data Object’.

Can you show what you’re actually adding to the list?

I’m adding a simple C++ UObject, anything will work as ListView will just give it to you so you handle it.

252218-object.png

(Note the Expand, it’s because I now use TreeView (similar to ListView)

Phew! I got it to work with C++ when (after!) I talked to OReillyEnt. Although, I did not like what I did there. Your method is just neat.

I was wondering what kind of object I could pass in pure BP. I got it to work by constructing a Primary Data Asset.

Again, thanks!

No problem :slight_smile: Nice it helped you doing things a bit cleaner. What kind of game are you developping ? :slight_smile:

Hello. If I want to remove a item in list view, What should I call function?..

and

I think list view and scroll box are similar.
but list view is more efficiently performence.
When should I use list view?..

This helped thx.

Do you know what “UserListEntry” interface is used for? Which class should implement it?

Hello Minnow,
I know it has been almost a year but did you find any solution for removing an item from the list view?

Im new to UE4 but I believe something has changed with this since this solution was posted. I have tried creating a ‘Data Object’ from a primary data asset class and a generic object class, and implemented the User Object List Entry Interface in both, but they wont show up as options in my listview widget for the entry widget class. However I can get a widget class with the implemented interface to show up. Am I missing something or doing something wrong? I dont know if it makes a difference but I am only using blueprints, no C++.

In Bp,use IUserObjectListEntry‘s OnListItemObjectSet,
In C++,use OnEntryWidgetGenerated EVENT to Update ListData,the index of Item,I use Bp to store the itemObject, and use IUserObjectListEntry‘s GetListItem on C++,which return by bp use the store itemobject。Use 4.22.2

蓝图里,可以直接使用OnListItemObjectSet,或者继承UserWidget实现SetListItemObjectInternal,但是UserWidget设计成只使用设计方案,所以在蓝图里数据转发一次,后期能支持事件update就好了

I finally got a (non-hacky) solution! Took me hours. Have been trying to figure out why I can’t set text in my child widget, why I can’t change variables. Why is tick not being called? Turns out, as people said, the ListView does not use the object you make and add to it, it uses it as an imprint and creates a totally unrelated object without the data.

However, it is possible to pass data from the object “imprint” onto the new data, through some magic.

Go into your class defaults for your Entry Widget. Delete whatever implemented interface is already there, and implement “User Object List Entry.”

Then, create this by finding the event on the Left Hand Side (you can’t search it), right click it, and hit IMPLEMENT (an override). You will then get this event, and just cast it to it’s own type, and then take the object and set your own data from it’s data.

Afterwards, set up what variables you want to set, make them instance editable and exposed on spawn. They can be anything.

Next, when you create your widget, pass in whatever data you want.

And then your end object will have all the data it wants! Hopefully this solution finds someone useful, it’s really as simple as this (albeit very convoluted). No need to make placeholder objects or arrays, etc.

6 Likes

The following solution works very well for me:

Just call the RegenerateAllEntries function which is defined in ListViewBase and inherited by ListView and all its children (CommonListView, EditorUtilityListView, TileView and TreeView)

broken link

1 Like