Update ListBox view after changin items inside the ListModel

Hi all,

I have a ListBox which is baked by a custom ListModel (which does extend the 'GLib.ListModel`).

I bind the ListModel to the ListBox by using the bind_model property.

I’m able to update the view whenever I add or remove item from the ListModel, since I use the items_changed signal that can be used to account for deletion and additions.

I also need to sort the items in the list and I’d like the view to reflect the new state of the model.

How can I trigger an update of the view whenever I sort my ListModel?
Is there any signal that enables me do operate an update on the view?

I also tried the show_all () function call, by with no luck.
Do I have to use the ListStore object?

Thanks is advance for the help,
Giacomo

You can just assume that the entire model changed and emit items-changed(all, all).

Hi @baedert, thanks for your answer!

In the end this was the right route to follow.

I started by using the set_sort_func, but it is not recommended to mix model and normal ListBox sorting, so after you answered I tried to call the items_changed (0, list.length (), list.length ()) and it worked.

So thank you for you answer!

If tomorrow I could find some time, I’ll post the code!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.