Can you put an std::shared_ptr inside a Gtk::TreeStore?



Hi all,

I'm working with a C++11 library which returns objects wrapped in
std::shared_ptr, and I'd like to display them in a Gtk::TreeView.

Some rows in the TreeView will be associated with the same object, while
others will be different, so the simplest way of keeping track of this
is to have the shared_ptr stored with the tree row itself, as opposed
to storing a string that is later parsed to reconstruct the object.

However this requires storing an std::shared_ptr in a Gtk::TreeModel,
and I am not sure how to do this.

Simply declaring the column works from the C++ side (in that the code
compiles), but I'm not sure what data type to put in Glade for the
column in the Gtk::TreeStore declaration.  If I use any of the standard
options (like gpointer) I get a conversion error when adding items to
the tree:

  Gtk-WARNING **: gtktreestore.c:856: Unable to convert from
    glibmm__CustomBoxed_St10shared_ptr...

Is there a way to make this work?  I don't need the TreeView to display
the column, just to store it to be retrieved later by the code as
needed.

Many thanks,
Adam.




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