How can I access child widget in GridView

I’m using Gtk 4 and a vala language.

I have GtkGridView with a BuilderListItemFactory that creates a list of GtkPictures.

My problem is that I want to access this picture widget to change its pixbuff.

That’s not how GtkGridView, or any of the list widgets in GTK4 work.

You store objects inside the model bound to the view widget, and when creating the row widgets in the factory, you bind properties on the widgets to properties on the objects inside the model. Whenever you change the model items, the widgets update themselves.

The problem is that you’re using GdkPixbuf, and GtkPicture does not have a pixbuf property you can bind, because pixbuf support is available only as a porting aid. You should use GdkTexture—or any other GdkPaintable implementation—to store the image data, not GdkPixbuf.


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