PDA

View Full Version : Shows the root of a tree



Alundra
2nd March 2015, 03:09
Hi,
I have a custom open file to only show a folder :
http://zupimages.net/up/15/10/koww.png
That works fine but the problem is once you enter a folder, you can't go on the root because the root is not showed on the tree list.
How shows the root on the tree list ? (I'm using a QTreeView with QFileSystemModel)
Thanks for the help

wysota
2nd March 2015, 07:20
QTreeView::rootIsDecorated

Alundra
2nd March 2015, 16:04
I tried but that only hide or show the line but doesn't show the root item.
The user must implements a custom model to have the root item ?

wysota
2nd March 2015, 17:35
The root index is never visible in a view.

neuronet
2nd March 2015, 17:42
As wysota said, the root is by design not visible. What you can do is add a single top-level item to your treeView, and make everything else a child of that. It will not be the real root of the tree, but will look like one. :)

Alundra
2nd March 2015, 17:58
Ok I understand. The only solution is to create a custom model or an easier way exists to achieve that ?

wysota
2nd March 2015, 20:45
You can use QFileSystemModel starting from one level higher and filter out all top-level items but the one you want using a simple proxy model.

Alundra
3rd March 2015, 17:10
Ok this solution looks good for one folder, I have question on the same topic :
Is it possible to show 2 folders using QFileSystemModel on the same tree with the root visible (possible custom root name) or a custom model has to be written ?

wysota
3rd March 2015, 20:32
Do the two folders share a common parent?

Alundra
3rd March 2015, 21:40
Like on the left (Engine and Game) :
https://docs.unrealengine.com/latest/images/Engine/Content/FBX/BestPractices/FBXBestPractices_MoveOrRename.jpg

wysota
3rd March 2015, 22:18
That doesn't really answer my question. A simple "yes" or "no" would be much better.

Alundra
4th March 2015, 01:54
Completely independent because not on the same place, can be one folder on "c:/" and another on "d:/"

wysota
4th March 2015, 06:26
Then making it derived from one model makes no sense. The easiest solution I can see is to have two models and a proxy model that will unite them. It is quite easy to implement.