Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top