Results 1 to 3 of 3

Thread: treeView and tableView linked to one model, can I set different namefilters?

  1. #1
    Join Date
    Jul 2009
    Posts
    92
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default treeView and tableView linked to one model, can I set different namefilters?

    I have a treeView and a tableView linked to a filesystemmodel. It works fine but I would like to show only dirs in the treeView and only files in the table view. Setting setNameFilters to a selection of files (e.g. *.txt") shows these in the tableView which is what I want. The treeView shows everything (dirs + files). Is there a way to show only dirs in the treeView independent of what I show in the tableView?

    I solved this earlier by using a 2nd model for the treeView and setting this to dirs only, and then coupling the two models, but this gives me drag/drop problems (I think). Any help appreciated.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: treeView and tableView linked to one model, can I set different namefilters?

    If you want one model, I guess you will need to use a proxy model. Think of it as a filter between your model and your view.
    You can use it to filter the results, to sort, etc...

  3. #3
    Join Date
    Jul 2009
    Posts
    92
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: treeView and tableView linked to one model, can I set different namefilters?

    thanks, I forgot that one. Tried it but the proxymodel doesn't know anything about files it just filters name. How to tell the proxymodel that we want to see only directories? I would have to check for every item in the tree if it is a directory or a file, and then tranlate that in some regexp? I don't know if that is possible...

Similar Threads

  1. Use QIterator on TreeView's model
    By LynneV in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2009, 19:46
  2. updating treeview from tableview
    By darshan in forum Qt Programming
    Replies: 4
    Last Post: 11th February 2009, 19:53
  3. Treeview and custom model
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 15th May 2007, 13:54
  4. TreeView custom model
    By steg90 in forum Newbie
    Replies: 1
    Last Post: 9th May 2007, 10:06
  5. TreeView, TableView
    By rbrand in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2006, 08: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.