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

1

6

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?

Balsamic answered 13/2, 2010 at 2:19 Comment(0)
M
7

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.

Maibach answered 13/2, 2010 at 2:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.