[PyQt] File Filtering using QFileSystemModel & QTreeView

David Boddie david at boddie.org.uk
Fri Mar 4 10:06:55 GMT 2011

On Tue Mar 1 23:28:01 GMT 2011, James Polk wrote:

> ....I've read all the documentation and for the life of me, I can't find
> the solution to initiate simple file filtering (by extension) in
> QFileSystemModel, and/or using QDirModel / QDir...
> I just want a Treeview of files and directory, but excluding certain files
> by their extension....seems pretty simple, right?....<sigh>...


This is where the problem lies:

    filter = ("JPG (*.jpg)");

You really need something like this:

    filter = ["*.jpg"]

David Boddie
Senior Technical Writer
Nokia, Qt

More information about the PyQt mailing list