[PyQt] File Filtering using QFileSystemModel & QTreeView

hosscomp ronnie.a.shoemaker at lmco.com
Fri Mar 9 21:55:48 GMT 2012


JPolk wrote
> 
> hey guys,
> ....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...
> 
> Here's my code:
> 
> # --------------------------------------
>     startDir = QString("C:/library/stuff")
> ....
>     model = QtGui.QFileSystemModel()
>     model.setRootPath(startDir)
> 
>     tree = QtGui.QTreeView()
>     tree.setModel(model)
> .....
>     tree.show()
> 
>     sys.exit(app.exec_())
> 
> 
> # ---------------------------------------------------
> _______________________________________________
> PyQt mailing list    PyQt@
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 

I got my TreeView to show the tree and filter the files correctly but can't
get it to take the root path setting. It always starts at the System level
showing C:, V:, E:, etc. I am running on a PC with Windows XP Professional.
My code looks similar to that above.

The model.setRootPath(startDir) has no effect regardless of what I set the
path to, ex: "C:\projects", or "C:/projects".
Any ideas? 

Ron



--
View this message in context: http://python.6.n6.nabble.com/File-Filtering-using-QFileSystemModel-QTreeView-tp1917066p4563713.html
Sent from the PyQt mailing list archive at Nabble.com.


More information about the PyQt mailing list