Question

I have a QTreeView with a QFileSystemModel as its model.

I can't figure out how to limit the depth of the tree. I would have thought it would be a function of the model?

What I mean is, if I set the depth to 1, for example, only the top level items would be shown (i.e no expand buttons on folders)

A depth of one would make the tree look like bog-standard details view in windows explorer.

I'm using PySide, but I can understand answers in PyQt or C++.

Was it helpful?

Solution

Not sure if this is what you're looking for, but if you're viewing the model with a QTreeView you can set the view's itemsExpandable and rootIsDecorated properties to false.

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