How to restrict directory viewing to a subtree?
I have a directory viewer which uses QDirModel and QTreeView. However, rather than inspecting a whole drive, I'd like to restrict the viewing/editing/etc to a particular folder, say "/tmp". I don't want users to see anything else but that subtree.
Is that possible to achieve using the default QDirModel and QTreeView (if so, how?), or should I implement a new custom model (if so, any tips/code would be extremely helpful)?
Re: How to restrict directory viewing to a subtree?
If you have such code:
Code:
tree->setModel(model);
then you can do:
Code:
tree->setRootIndex(model->index("/tmp"));
and the root index of your tree would be the /tmp directory.
Re: How to restrict directory viewing to a subtree?
thanks for that - completely missed that in the documentation