Treeview Setting Selection within multilevel treemodel



I have a treeview widget that has an associated treemodel with multiple levels (parents with children, parents with children with children, etc…).  What I want to do is when I display the treeview I want to set the selection to a saved selection.  I know how to change the section using

 

m_TreeView.expand_row(Gtk::TreePath ("1"), true)

m_TreeView.scroll_to_row(Gtk::TreePath ("1:2")) ;

                        m_TreeView.set_cursor(Gtk::TreePath ("1:2"));

 

where “1:2” is the parent and corresponding child row.

 

My treemodel is just one column with a single string in each row.  What I want to do is set the treeview so that the cursor is on “STRINGX”.  I can avoid having to search the treemodel for “STRINGX” because I can know the row of “STRINGX” from when I am building the treemodel.  I am adding the nodes by:

 

{
      row = *(m_refTreeStore->append());
}
else
{
        
       row = *(m_refTreeStore->append( (*pParentTreeRow).children()));

}
 

Row // fill in row data here

 

 

 

How can I convert the row object to its corresponding treemodel level (such as 2:4:5) or path so that I can pass the specific level position to the Treeview::scroll_to_row() method ?

 

 

Thanks,

Bill

 

 

 

 



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