Re: [gtkmm] TreeView



> Hi guys could somebody help me?
> In a treeview, when I populate it, I want a particular row 
> selected(during the populating i think) and also i wane have it
expanded 
> so I can see the underlaying targets but I can't find out how to do
this.
> 


hi

it seems to me that if you append/insert/prepend a row to the treestore
you get an iterator as return value... using this iterator it should be
simple to get everything else you'd need.

Something along the lines of:

Gtk::TreeModel::iterator iter = mrefTreeStore->append();
Gtk::TreeModel::Path path = mrefTreeStore->get_path( iter );
Glib::RefPtr<Gtk::TreeSelection> refSelection =
	mTreeView->get_selection();
refSelection->select( path );

But perhaps you don't even need to do it half so complicated:

http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1TreeSelection.html#a21

you can pass iterators, rows or paths to the TreeSelection object, no
need to do any conversions between them just to select a row!

If you want to expand the node you need the path anyway, so you can use
the first code fragment I posted. If you want to expand a row you have
to use

mTreeView->expand_row( path, [true|false] );

http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1TreeView.html#a60

hth




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