Re: Using Gio::ListStore with custom content type and Gtk::ListView (Gtkmm 4)



Hi again,

From an earlier thread I found the columnview demo (https://gitlab.gnome.org/GNOME/gtkmm/-/blob/master/demos/gtk-demo/example_listview_columnview.cc), which was exactly what I needed!

In case anyone runs into the same problem as I did, my mistake was using `std::make_shared` to create new instances, when I should have been using `Glib::make_refptr_for_instance`.

Have a good day,

Jackson

On Sun, Feb 20, 2022 at 6:36 PM Jackson Campolattaro <jackcamp vt edu> wrote:
Hello,

I would like to use `Gtk::ListView` to display a custom type held in a `Gio::ListStore`, but inside my `on_bind(list_item)` handler `list_item->get_item()` returns a null RefPtr. I also get the same "Failed to wrap" error seen [here](https://stackoverflow.com/questions/3233727/what-has-to-be-glibinited-in-order-to-use-glibwrap), but adding `Glib::init()` at the start of my program didn't help.

I haven't been able to get the ListStore working with any types, including the example custom `Glib::Object` shown [here](https://github.com/GNOME/glibmm/blob/master/examples/properties/properties_example.cc) and provided Object types like `Gtk::Box`. `Gtk::StringList` works fine, so I suspect the problem lies in how I'm using the ListStore.

Has anyone produced a known-working example of a `Gtk::ListView` which displays custom objects?

Kind regards,

Jackson Campolattaro

--
Jackson Campolattaro
Masters Student at TU Delft


--
Jackson Campolattaro
Masters Student at TU Delft


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]