# Am unable to figure out this issue with ListView and UserObjectListEntry \[C++\]

**URL:** <https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784>\
**Category:** Programming & Scripting\
**Tags:** listview, text, unreal-engine, CPP, question\
**Created:** [April 28, 2024, 6:29pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784 "2024-04-28T18:29:54Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![SCARBLAZ1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SCARBLAZ1](https://forums.unrealengine.com/u/SCARBLAZ1)\
**Post date:** [April 28, 2024, 6:29pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/1 "2024-04-28T18:29:54Z")

</div>

Initially I have a ListView Widget and also A item which inherits from UserObjectListEntry as it is mandatory.

Creating item and displaying data of item is working properly at beginning but,

**What I Am Trying to do is:**

There are a few bind widgets in my item, and i want to change data of those widgets on runtime.

Lets say I want to change text of UTextBlock on some button click on other method.

**What I tried:**

I have tried directly accessing the pointer to bind widget and changing. In debug message it is changing but on screen UI value is not changing.

I have tried adding same pointer to a TArray on creating of item , and accessing bind widget, ofc it is same whether through TArray or directly, but yeah i did tried it just to be sure.

**What I want:**

I want to change UTextBlock-\>SetText() after already adding item to ListView.

**Alternative that are in my mind:**

Maybe I could remove the item i want to update and create again with the updated data . But I dont think it will be an ideal solution. Hopefully i get help from other experts before I choose this last workaround solution.

_ **Am not a highly professional Unreal Dev, I appreciate polite and detailed responses.** _

---

<div class="post-metadata">

**Author:** ![adlab](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@adlab](https://forums.unrealengine.com/u/adlab)\
**Post date:** [April 28, 2024, 6:35pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/2 "2024-04-28T18:35:36Z")

</div>

To change the text of a UTextBlock widget in a ListView widget after the item has been added, you can use the `SetText` method of the UTextBlock widget.

Here’s an example of how you can do this:

1. Get a reference to the UTextBlock widget in your item class:

```auto
UPROPERTY(EditAnywhere, Category = "Widgets")
    UTextBlock* TextBlock;

```

1. In your `OnListItemObjectSet` function, get a reference to the UTextBlock widget and change its text:

```auto
void IMyListView::OnListItemObjectSet(IUserObjectListEntry* NewEntry, IUserObjectListEntry* OldEntry)
{
    if (OldEntry && OldEntry->GetWidget() && OldEntry->GetWidget()->GetClass() == UTextBlock::StaticClass())
    {
        UTextBlock* TextBlock = static_cast<UTextBlock*>(OldEntry->GetWidget());
        TextBlock->SetText("New Text");
    }
}

```

This will change the text of the UTextBlock widget in the old entry to “New Text”.

Note that you need to make sure that the UTextBlock widget is properly initialized and has a valid pointer to the UTextBlock class before calling the `SetText` method.

---

<div class="post-metadata">

**Author:** ![SCARBLAZ1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SCARBLAZ1](https://forums.unrealengine.com/u/SCARBLAZ1)\
**Post date:** [April 28, 2024, 6:39pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/3 "2024-04-28T18:39:27Z")

</div>

Where should i call `OnListItemObjectSet(args)`?  
I suppose it is called automatically, i mean am not getting the point. i want to update text on button click of some other actor component.

am really sorry if am not getting what you are trying to convey.

---

<div class="post-metadata">

**Author:** ![adlab](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@adlab](https://forums.unrealengine.com/u/adlab)\
**Post date:** [April 28, 2024, 6:43pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/4 "2024-04-28T18:43:02Z")

</div>

You should call OnListItemObjectSet(args) in the ListView widget’s implementation. This function is called whenever a new item is added to the list or an existing item’s properties change. In this case, you want to change the text of a UTextBlock widget in the list, so you should call OnListItemObjectSet(args) in the ListView widget’s implementation.

---

<div class="post-metadata">

**Author:** ![SCARBLAZ1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SCARBLAZ1](https://forums.unrealengine.com/u/SCARBLAZ1)\
**Post date:** [April 28, 2024, 6:46pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/5 "2024-04-28T18:46:06Z")

</div>

whatever you are saying “This function is called whenever a new item is added to the list or an existing item’s properties change”.

but that functionality is already being handled by overridden method `OnListItemObjectSet(args)`

Edit:  
on creating item, am already assigning values, but i want to change that existing data on gameplay at any time of player’s need.

---

<div class="post-metadata">

**Author:** ![adlab](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@adlab](https://forums.unrealengine.com/u/adlab)\
**Post date:** [April 28, 2024, 6:48pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/6 "2024-04-28T18:48:50Z")

</div>

The `OnListItemObjectSet` function is called automatically by the ListView widget when a new item is added to the list or an existing item is replaced. It is not called on button click of another actor component.

If you want to update the text of a UTextBlock widget in a ListView widget on button click of another actor component, you can add an event listener to the button component that calls the `SetText` method of the UTextBlock widget.

Here’s an example of how you can do this:

1. Add an event listener to the button component that calls the `SetText` method of the UTextBlock widget:

```auto
UPROPERTY(EditAnywhere, Category = "Widgets")
UTextBlock* TextBlock;

void MyButtonComponent::OnButtonClicked()
{
    if (TextBlock)
    {
        TextBlock->SetText("New Text");
    }
}

```

1. In your ListView widget, make sure that the UTextBlock widget is properly initialized and has a valid pointer to the UTextBlock class.

---

<div class="post-metadata">

**Author:** ![SCARBLAZ1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SCARBLAZ1](https://forums.unrealengine.com/u/SCARBLAZ1)\
**Post date:** [April 28, 2024, 6:51pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/7 "2024-04-28T18:51:38Z")

</div>

Okay so , of what i understood is whenever is call function UTextBlock-\>SetText(), OnListItemObjectSet is called which have args of old and new entries, and i should get old entry’s text value and sent that to new entry?

Edit:

just a quick question, we are setting text again in OnListItemObjectSet() wont it call the OnListItemObjectSet() again to loop?

---

<div class="post-metadata">

**Author:** ![adlab](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@adlab](https://forums.unrealengine.com/u/adlab)\
**Post date:** [April 28, 2024, 6:56pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/8 "2024-04-28T18:56:52Z")

</div>

Yes, that is correct. Whenever you call the `SetText()` method of a `UTextBlock` widget, the `OnListItemObjectSet()` function of the `ListView` widget will be called. This function is called automatically by the `ListView` widget whenever a new item is added to the list or an existing item is replaced.

If you want to update the text of a `UTextBlock` widget in a `ListView` widget on button click of another actor component, you can add an event listener to the button component that calls the `SetText()` method of the `UTextBlock` widget.

Here’s an example of how you can do this:

1. In your `ListView` widget, make sure that the `UTextBlock` widget is properly initialized and has a valid pointer to the `UTextBlock` class.
2. Add an event listener to the button component that calls the `SetText()` method of the `UTextBlock` widget.
3. In the `OnButtonClicked()` function of the button component, get the text value of the old entry and set the text value of the new entry to it.

Here’s an example of how you can implement this:

```auto
UPROPERTY(EditAnywhere, Category = "Widgets")
UTextBlock* TextBlock;

void MyButtonComponent::OnButtonClicked()
{
    if (TextBlock)
    {
        // Get the text value of the old entry
        FString OldText = TextBlock->GetText();

        // Set the text value of the new entry to the old text value
        TextBlock->SetText(OldText);
    }
}

```

Note that calling the `SetText()` method of the `UTextBlock` widget will not cause the `OnListItemObjectSet()` function to be called again, as this function is called automatically by the `ListView` widget whenever a new item is added to the list or an existing item is replaced.

---

<div class="post-metadata">

**Author:** ![SCARBLAZ1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SCARBLAZ1](https://forums.unrealengine.com/u/SCARBLAZ1)\
**Post date:** [April 28, 2024, 6:59pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/9 "2024-04-28T18:59:13Z")

</div>

understood, if you dont mind, can i just know what goes in method OnListItemObjectSet() so that i will be able to change old text to new text?

---

<div class="post-metadata">

**Author:** ![adlab](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@adlab](https://forums.unrealengine.com/u/adlab)\
**Post date:** [April 28, 2024, 7:16pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/10 "2024-04-28T19:16:43Z")

</div>

The `OnListItemObjectSet()` function is called automatically by the `ListView` widget whenever a new item is added to the list or an existing item is replaced. It is not called when you call the `SetText()` method of a `UTextBlock` widget directly.

To change the text of a `UTextBlock` widget in a `ListView` widget on button click of another actor component, you can add an event listener to the button component that calls the `SetText()` method of the `UTextBlock` widget.

Here’s an example of how you can do this:

1. In your `ListView` widget, make sure that the `UTextBlock` widget is properly initialized and has a valid pointer to the `UTextBlock` class.
2. Add an event listener to the button component that calls the `SetText()` method of the `UTextBlock` widget.
3. In the `OnButtonClicked()` function of the button component, get the text value of the old entry and set the text value of the new entry to it.

Here’s an example of how you can implement this:

```auto
UPROPERTY(EditAnywhere, Category = "Widgets")
UTextBlock* TextBlock;

void MyButtonComponent::OnButtonClicked()
{
    if (TextBlock)
    {
        // Get the text value of the old entry
        FString OldText = TextBlock->GetText();

        // Set the text value of the new entry to the old text value
        TextBlock->SetText(OldText);
    }
}

```

Note that calling the `SetText()` method of the `UTextBlock` widget will not cause the `OnListItemObjectSet()` function to be called again, as this function is called automatically by the `ListView` widget whenever a new item is added to the list or an existing item is replaced.

---

<div class="post-metadata">

**Author:** ![SCARBLAZ1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SCARBLAZ1](https://forums.unrealengine.com/u/SCARBLAZ1)\
**Post date:** [April 28, 2024, 7:40pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/11 "2024-04-28T19:40:33Z")

</div>

Hey man, it is not working. i have debug log OnListItemObjectSet() , it is not even triggering.  
also the method args you mentioned are not matching what it is showing here in visual studio.  
here is it …

```auto
void UMyItemClass::OnListItemObjectSet(UObject* ListItemObject)
{
    UE_LOG(LogTemp, Display, TEXT("OnListItemObjectSet Called"));
}

```

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [April 29, 2024, 2:57pm UTC](https://forums.unrealengine.com/t/am-unable-to-figure-out-this-issue-with-listview-and-userobjectlistentry-c/1826784/12 "2024-04-29T14:57:46Z")

</div>

Don’t fall for the chatgpt nonsense.

It is a bit unclear what you tried to do and what failed.  
If I get this right, you have a list item widget based on a C++ class which relies on BindWidget to reference a text block.  
You want to change the text block upon pressing a button. Where is the button ? Is it also part of the list item widget ? Or is it part of a different widget ?  
If it’s a different widget, how do you know which list entry to modify ?
