dimanche 27 décembre 2015

Is it possible to instruct a `Gtk::TreeView` to display a custom type?

There is something I don't understand how to do with Gtkmm 3.

I have a custom business type that I have declared like this:

enum class Eurocents : int {};

I would like to render this type into a Gtk::TreeView which has a Gtk::ListStore as model. So I declare a Gtk::TreeModelColumn<Eurocents>, and add it to the model. I then append_column this model column to the Gtk::TreeView with an appropriate title.

I then append_row to the model and set the value corresponding to the column to (Eurocents)100.

The result I get is that the cell is displayed empty. Understandably so, because I would not expect Gtkmm to know how to render my arbitrary type.

I would like to instruct Gtkmm on how to render my type. I already know how to display Glib types like Glib::ustring, but is it possible to code columns that can display arbitrary types like this?

Aucun commentaire:

Enregistrer un commentaire