Gtk4 ListView header rows

Hello,

I see that header rows appear to be possible for ListView since gtk 4.12, since the header factory was introduced. I even found the “Alternative Settings” sample in the gtk4-demo application that makes use of them. But somehow I can’t find how to specify which header should apply for each list item.

In gtk3, I was using set_header_func for that purpose for instance. Now I set the header factory and then… I don’t know what to do after that. I get a blank header at the top of the list, and that’s it. How do I say that for instance for the 4th row there should be a header row “X”, and for the 9th row, a header row “Y”?

I currently populate my ListView calling set_model and giving it a ListStore.

Thank you!

Emmanuel

so I found SectionModel. I now think I must inherit from gio.ListStore and implement SectionModel there, then give that to my ListView. Hopefully that works out.

EDIT: made it work, implementing SectionModel and ListModel.

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