Re: Using Trees
- From: Murray Cumming <murrayc murrayc com>
- To: Joe LaBarbera <jlabarbera11 gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Using Trees
- Date: Sun, 27 Jun 2010 12:07:18 +0200
On Sat, 2010-06-26 at 14:28 -0400, Joe LaBarbera wrote:
> Hi,
>
> I was trying to append allow a user to click a button that would allow
> an additional column to be appended to my tree.
>
> This is what I have:
>
> void treetstruct::add_column()
> {
> Gtk::TreeModelColumn<unsigned> newcol = columns.addcol();
>
> treeview.append_column_editable("New", columns.cols.back());
> }
>
> Gtk::TreeModelColumn<unsigned> addcol()
> {
> Gtk::TreeModelColumn<unsigned> newcol;
> cols.push_back(newcol);
> add(cols.back());
>
> return cols.back();
> }
But your model knows nothing about these new columns.
TreeModelColumnRecord (your cols) is just a way to remember details
about model columns. You probably supplied it to a ListStore or
TreeStore create() method:
http://library.gnome.org/devel/gtkmm/stable/classGtk_1_1ListStore.html#aaa6c530560f66872482a0650739276c5
But your cols object is not shared. The model won't change in response
if you later change the TreeModelColumnRecord.
Basically, there is no TreeModel::add_column() method. You must recreate
your entire model when you want to add a column. I often wish that it
was more flexible, but it does make some sense: Adding a column means
that you've changed your data structure.
> The column will appear; however, when I attempt to change values, they
> are automatically erased, and there are many errors that appear in the
> command line. If anyone could help, even by providing additional
> information on trees in general, I would really appreciate it.
--
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]