Results 1 to 9 of 9

Thread: QFileSystemModel stylesheet conflict

  1. #1
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Exclamation QFileSystemModel stylesheet conflict

    Hi all,
    I have problem of conflict with stylesheet and QFileSystemModel arrows.
    Is QFileSystemModel should be avoided to be used ? I read on different forums that it's deprecated like QDirModel.
    The problem is when I go in a folder but it has no sub-folder and then if you close the parent and reopen, it's replaced by stylesheet.
    I read that a custom QFileSystemModel can be faster than using the one in Qt ?
    Is it possible to inherit QFileSystemModel to avoid this arrow and just use the QTreeView stylesheet ?
    I already inherit QFileIconProvider to have custom folder icon.
    Is it possible to have this folder icon in stylesheet ?
    Thanks for the help
    Last edited by Alundra; 4th June 2014 at 17:10.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QFileSystemModel stylesheet conflict

    What do you mean that a folder is replaced by stylesheet? What do you mean by "QTreeView stylesheet"? QTreeView doesn't have any stylesheets...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileSystemModel stylesheet conflict

    I mean it uses :
    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);
    }
    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.
    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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QFileSystemModel stylesheet conflict

    What you explain here has nothing to do with QFileSystemModel.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileSystemModel stylesheet conflict

    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QFileSystemModel stylesheet conflict

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileSystemModel stylesheet conflict

    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QFileSystemModel stylesheet conflict

    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().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileSystemModel stylesheet conflict

    Here the solution :
    Qt Code:
    1. class CFileSystemModel : public QFileSystemModel
    2. {
    3. public:
    4.  
    5. CFileSystemModel( QObject* Parent ) :
    6. QFileSystemModel( Parent )
    7. {
    8. }
    9.  
    10. virtual bool hasChildren( const QModelIndex& parent = QModelIndex() ) const
    11. {
    12. if( parent.flags() & Qt::ItemNeverHasChildren )
    13. return false;
    14. return QDirIterator( filePath( parent ), filter(), QDirIterator::NoIteratorFlags ).hasNext();
    15. }
    16. };
    To copy to clipboard, switch view to plain text mode 
    That solves the problem of stylesheet and the problem of arrow when empty.
    Last edited by Alundra; 6th June 2014 at 18:02.

Similar Threads

  1. OpenCV conflict with QIMage in Ubuntu
    By merajc in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2014, 18:59
  2. Handle QContextMenuEvent conflict
    By cia.michele in forum Qt Programming
    Replies: 7
    Last Post: 2nd May 2011, 14:59
  3. Replies: 0
    Last Post: 20th January 2010, 19:51
  4. MinGW conflict?
    By Paolo_R in forum Newbie
    Replies: 3
    Last Post: 30th June 2009, 05:16
  5. Framebuffer conflict
    By Vidar Bøe in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 21st November 2008, 10:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.