Thursday 15 May 2014

c++ - Hide filtered files with QFileSystemModel, setNameFilterDisables(false) hides everything -


I am trying to make simple file filters for my visitors.
Idea is only showing files with filters and hide permissions other (do not disable them)
Some useful answers were found, and using those examples, I wrote this simple code:

  QDir dir ("c: / projects / qt / data / spyro /") ; QFileSystemModel * Model = New QFileSystemModel; Model & gt; SetRootPath (dir.path ()); Model & gt; SetReadOnly (true); Model- & gt; Set filter (QDir :: Dirs; QDir :: Files | QDir :: NoDotAndDotDot); Model- & gt; Setnam Filter (Qestring List)  SetModel (model);  

However, it is not working as expected. When using the line with the setNameFilterDisables (false) , I do not get any files.
This is not the expected behavior for me because I hope that such files which do not pass the filter are not displayed at all.
This document is described in:

So, how to properly filter files and display only those filtered?

You forgot the tree set root index:

  m_treeView- > SetRootIndex (model-> gt; index (dir.path ()));  

If you want to show directories with filtered files, use QDir :: AllDirs flag favicon QDir :: Dirs .


No comments:

Post a Comment