Re: custom TreeModel



Have you declared your custom TreeModel something like

class MyTreeModel : public Glib::Object, public Gtk::TreeModel

That's wrong. Glib::Object must be declared after the base interface(s):

class MyTreeModel : public Gtk::TreeModel, public Glib::Object

This restriction was introduced about 5 years ago due to modifications of GLib. I thought it was documented somewhere, but now I can't find any such documentation.

Kjell

On 2019-12-11 23:39, danny via gtkmm-list wrote:
hello all,

can anyone tell me the list of methods to override in order to create a custom TreeModel?

I currently have these:
  virtual Gtk::TreeModelFlags get_flags_vfunc() const;
   virtual int get_n_columns_vfunc() const;
   virtual GType get_column_type_vfunc(int index) const;
   virtual void get_value_vfunc(const TreeModel::iterator& iter, int column, Glib::ValueBase& value) const;

   bool iter_next_vfunc(const iterator& iter, iterator& iter_next) const;

   virtual bool iter_children_vfunc(const iterator& parent, iterator& iter) const;
   virtual bool iter_has_child_vfunc(const iterator& iter) const;
   virtual int iter_n_children_vfunc(const iterator& iter) const;
   virtual int iter_n_root_children_vfunc() const;
   virtual bool iter_nth_child_vfunc(const iterator& parent, int n, iterator& iter) const;
   virtual bool iter_nth_root_child_vfunc(int n, iterator& iter) const;
   virtual bool iter_parent_vfunc(const iterator& child, iterator& iter) const;
   virtual Path get_path_vfunc(const iterator& iter) const;
   virtual bool get_iter_vfunc(const Path& path, iterator& iter) const;

but I keep getting this when I try to set the model in the treeview:
(gtkmm-demo:6627): GLib-GObject-WARNING **: attempting to add an interface (GtkTreeModel) to class (gtkmm__CustomObject_16Memory_TreeModel) after class_init
(gtkmm-demo:6627): Gtk-CRITICAL **: gtk_tree_view_set_model: assertion 'model == NULL || GTK_IS_TREE_MODEL (model)' failed

regards, danny.




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