Re: [gtkmm] getting the content of a Row in a Treeview



Use the TreePath to build an iterator which points at the activated row.
Dereferencing the iterator will then obtain the Row object required. I
have code that looks something like this (rewritten to make sense
without all the class definitions and other stuff going on)

void WindowClass::on_treeview_row_activated(const Gtk::TreePath &path,
Gtk::TreeViewColumn *column) {
  Gtk::TreeModel::iterator iter =
treeview.get_model()->get_iter(const_cast<Gtk::TreePath&>(path));

  // *iter is then the activated Row
}

I know this is kind of messy, but I wrote the code I based that snippet
on a long time ago and haven't touched it for some time. It's possible
ti doesn't even work anymore, but it should be vaguely right.

On Sat, 2003-06-07 at 03:43, Andre Leubner wrote:
> Hi,
> 
> ok, i have a TreeView, i'm catching the row_activated signal.
> and now i need the content(ustring) of the selected row.
> 
> here some code i already tried, without success:
> 
> void SimpleEdit::on_row_activated(const Gtk::TreePath & path,Gtk::TreeViewColumn * col) //row_activated sig
> {
> 	//Gtk::TreeSelection * selection;
> 	Glib::RefPtr<Gtk::TreeSelection> selection;
> 	selection=m_listview.get_selection();
> 	//selection->get_selected();
> 	Gtk::TreeModel::iterator iter=selection->get_selected();
> 
> 	Glib::RefPtr<Gtk::TreeModel> model;
> 	model=m_listview.get_model();
> 	//g_print(model->get_string(iter));
> 	//std::cout << model->get_string(iter)<<std::endl;//this gives me the number of the selected row in the list
> 	//std::cout << (Glib::ustring*)(m_Columns.m_col_name)<<std::endl;//doesn't working
> }
> 
> i want to do it this way:
> 	//Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
> 	Gtk::TreeModel::Row row = m_refTreeModel->get_activated_row()//get_activated_row doesn't exist
> 
> 	Glib::ustring wanted_content=row[m_Columns.m_col_name];
> 
> but i can't find a way to get the activated row...
> 
> 
> Andre Leubner
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
-- 
Matthew Walton <matthew alledora co uk>




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