I have a widget blueprint that uses a listview to display a history of a certain kind of event in the game.
After making this I realised this tool could also be used for other kinds of “event”. But rather than copy and paste the whole thing, I was hoping it would be possible to create a generic “list” control to which I simply set the entry widget type and then pass in objects appropriate for that type.
Is it possible to make something generic in this way with a ListView control?
Hi Daniel,
It isn’t possible to change a ListView’s EntryWidgetClass at runtime, and It has to be set before populating the list. To make it feel dynamic, use a UObject (a “payload”) for each row to hold its data, and let the row widget build itself based on that payload.
There are a few patterns that can fit what you want to get:
1 - Base Payload + Subclasses:
- Create a base payload (e.g., ItemPayload) with common fields.
- Add subclasses (e.g., ItemPayload_TypeA, ItemPayload_TypeB) for variations.
- In the entry widget, detect the payload type and adjust the UI (e.g., using a WidgetSwitcher or toggling sections).
2 - Entry Widget as a Factory:
- The entry widget dynamically creates child widgets based on the payload and attaches them to a container (VerticalBox, Overlay, etc.).
- ListView reuses rows, so always clear containers and reset state before rebuilding.
- Clean up properly in OnListItemObjectSet.
By using one of these two patterns, you can achieve a result similar to “reusing the list”.
If you want to do more advanced things, the only option would be to do C++ implementations.
Would you provide more details on how to implement it?
Best regards,
Gonzalo