Results 1 to 3 of 3

Thread: How to restrict directory viewing to a subtree?

  1. #1
    Join Date
    Jan 2009
    Posts
    20
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X

    Default 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)?

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to restrict directory viewing to a subtree?

    If you have such code:
    Qt Code:
    1. QDirModel * model = new QDirModel;
    2. QTreeView * tree = new QTreeView(this);
    3. tree->setModel(model);
    To copy to clipboard, switch view to plain text mode 
    then you can do:
    Qt Code:
    1. tree->setRootIndex(model->index("/tmp"));
    To copy to clipboard, switch view to plain text mode 
    and the root index of your tree would be the /tmp directory.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. The following user says thank you to faldzip for this useful post:

    xfurrier (10th April 2009)

  4. #3
    Join Date
    Jan 2009
    Posts
    20
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: How to restrict directory viewing to a subtree?

    thanks for that - completely missed that in the documentation

Similar Threads

  1. install help nedded.
    By aj2903 in forum Installation and Deployment
    Replies: 9
    Last Post: 13th November 2008, 07:57
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  3. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54

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.