Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Gtk, what's the difference between a TreePath and a TreeIter?

I've been learning to use TreeViews, and these two types are often used for accessing a particular row of a tree. I don't really understand the difference between the two. My code is working--I convert back and forth between the two based on a function's required parameters--but not based on any real understanding of why.

What is the difference between these two types?

like image 670
Matthew Avatar asked Feb 13 '10 02:02

Matthew


1 Answers

There's a detailed explanation of this here from the Gtk folks. Essentially, a TreePath is a way to describe the logical position of a row in the model. For example, the TreePath "5:3:2" means:

  • look at the children of the sixth [5] node at this level; then,
  • look at the children of the fourth [3] node at this level; then,
  • look at the third [2] node at this level

This exactly describes the one node you're after by drilling through each tree level.

By comparison, a TreeIter is a more direct reference to the node in question, more like a pointer to a specific node.

like image 117
John Feminella Avatar answered Sep 25 '22 19:09

John Feminella