What do you mean that a folder is replaced by stylesheet? What do you mean by "QTreeView stylesheet"? QTreeView doesn't have any stylesheets...
What do you mean that a folder is replaced by stylesheet? What do you mean by "QTreeView stylesheet"? QTreeView doesn't have any stylesheets...
I mean it uses :
But that use this stylesheet only when I close a parent and reopen it with all item opened, before doing this action, it has arrow on the left of each item.QTreeView::branch:has-siblings:!adjoins-item
{
border-image: url(StyleSheets/Default/branch-vline.png);
}
QTreeView::branch:has-siblings:adjoins-item
{
border-image: url(StyleSheets/Default/branch-more.png);
}
QTreeView::branch:!has-children:!has-siblings:adjoins-item
{
border-image: url(StyleSheets/Default/branch-end.png);
}
One thing weird too is that replace an item with no children by the good stylesheet image but before doing the action, one arrow is on the left of the item.
Here a screenshot before and after doing this action. I would only use the stylesheet if possible.
Step1 : I open a folder
http://uppix.com/f-Step153906b180016a77f.png
Step2 : I open each folder, they have no children
http://uppix.com/f-Step253906b690016a781.png
Step3 : I close the parent folder and reopen it
http://uppix.com/f-Step353906b890016a782.png
What you explain here has nothing to do with QFileSystemModel.
I use differents QTreeView in different widgets I never have problem, only using QFileSystemModel on a QTreeView gives me this problem.
If it's not about QFileSystemModel, I don't understand.
QFileSystemModel is a model while you are having problems with the view. The parts of the view that you are styling are not related to the content of the model.
I need your help to have the correct part because in the doc of Qt there is no informations, that demand to inherit one class to avoid this Qt bug ?
EDIT : Apparently to avoid this problem an item delegate has to be written ? I have tried without stylesheet, it contains the problem too.
Last edited by Alundra; 5th June 2014 at 19:40.
Writing a delegate will not help as, again, what you are styling is not related to the model in any way. It is part of the view so the only way to override it is to subclass the view and reimplement drawBranches() and drawRow().
Here the solution :
That solves the problem of stylesheet and the problem of arrow when empty.Qt Code:
class CFileSystemModel : public QFileSystemModel { public: QFileSystemModel( Parent ) { } { if( parent.flags() & Qt::ItemNeverHasChildren ) return false; return QDirIterator( filePath( parent ), filter(), QDirIterator::NoIteratorFlags ).hasNext(); } };To copy to clipboard, switch view to plain text mode
Last edited by Alundra; 6th June 2014 at 18:02.
Bookmarks