As I work through tree models I am struck by the ubiquity of the "invalid" model index (QModelIndex()). Not only is it used as the index of the root, it is also expected you return QModelIndex() as the parent of the root (documentation)

It seems there should be two things here, and this convention of using QModelIndex() for what seem to be different things is confusing. It seems the root should be a special valid index (one that doesn't correspond to data displayed in the tree), and we should have another value for truly invalid indexes (e.g., that correspond to things that do not exist, or are out of bounds of the model, things like that).

The root index seems special, real, and functional (i.e., the root index is the parent of all top-level items in the model, and is the starting point for the traversal of the entire tree structure). Hence, calling its index "invalid" seems almost misleading. Further, not only does the parent of the root not have this special status, it does not even exist at a conceptual level in the model. Even so, we use the exact same index as we do for the root.

The noble root of our trees seems to be getting short shrift.