Results 1 to 4 of 4

Thread: QFileSystemModel root

  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 root

    Hi all,
    Using a QFileSystemModel you never have the root item showed.
    When you use it for an explorer it's impossible to go back at the root.
    Does a way exists to show the root item ?
    Is it possible to use multiple QFileSystemModel in one model to show multiple folder ?
    To have a correct result the root of each folder should be shown.
    Thanks for the help

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

    Default Re: QFileSystemModel root

    By definition a root index of the view is the index whose children are shown in the view. This is the same for the file system model -- a root is a directory whose children are to be represented in the model. If you want to see the current root directory as well then either change the root of the model to the parent directory or wrap the model in a custom proxy model that will return a modified model structure.
    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 root

    I tried :
    Qt Code:
    1. ListTreeModel->setRootPath( QDir::currentPath() );
    2. m_ListTree->setRootIndex( ListTreeModel->index( "Content/" ) );
    To copy to clipboard, switch view to plain text mode 
    But the root is not shown too.
    The proxy is the last option you said, sounds hard to just have a root :/
    But the good point is proxy can show multiple tree if I understand what you said.
    Is it possible to have more information about this proxy since I never wrote a proxy model ?
    Last edited by Alundra; 9th June 2014 at 13:51.

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

    Default Re: QFileSystemModel root

    As I said the root is by definition not shown in the view. You need to have a model that has only one element on the top-most level -- your "root" and attach the "real data" to this single element as its children.
    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.


Similar Threads

  1. QDir::root ()
    By RenanBS in forum Qt Programming
    Replies: 10
    Last Post: 6th June 2014, 19:00
  2. debugging as root
    By weaver4 in forum Qt Programming
    Replies: 0
    Last Post: 13th February 2012, 22:10
  3. Find the Qt root directory
    By sajis997 in forum Newbie
    Replies: 1
    Last Post: 15th July 2011, 23:52
  4. how to run QT application with root permission
    By noa l in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2010, 14:32
  5. root-priviliges in application
    By bkv in forum KDE Forum
    Replies: 2
    Last Post: 29th October 2006, 19:58

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.