PDA

View Full Version : treeView and tableView linked to one model, can I set different namefilters?



qt_gotcha
5th September 2010, 09:51
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.

tbscope
5th September 2010, 11:13
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...

qt_gotcha
7th September 2010, 08:38
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...