[PyQt] Linux: Problem with QTreeView and Dot Directories

Hans-Peter Jansen hpj at urpla.net
Thu Jul 7 16:30:54 BST 2016

Dear Gottfried,

On Donnerstag, 7. Juli 2016 10:08:00 Gottfried Müller wrote:
> I am using Python 3.5, PyQt 5.6 and Qt 5.6 (Manjaro distribution)
> You can follow the problem with the small python script in the attachment.
> There is a combobox with 2 entries (Home and a dot directory in the home
> path). After the start of the example program switch to the "UserShare"
> entry of the combobox. The treeview is empty now (I hope so). When you
> go back to the "Home" entry of the combobox, you will find beside of
> other directories in your home path (maybe) still the entry ".test". The
> model filter "QDir.AllDirs | QDir.NoDotAndDotDot" should not allow
> showing this entry. All other dot directories in the home path are hidden.

QDir.NoDot and friends act on "." and ".." entries only, nothing else.
By default, hidden entries are hidden, as you notice, and can be made visible 
with QDir.Hidden. 

When you use the .test/share path, you explicitly make .test part of the 

> Is this a feature or a bug?
> Is it a problem of PyQt or Qt? I suppose it is more a problem of Qt. I
> never wrote a C++ program. So it is not easy to me coding this example
> in C++.

It's an unfortunate usage pattern of QFileSystemModel. 

The easiest workaround for your issue is using a QSortFilterProxyModel with a 
'^[^\.]' regexp filter between model and view.


More information about the PyQt mailing list