I use the QFileSystemModel
, but I just want to show the tree directory in QTreeView
. I dont want to show Size,Type and Date Modified.
This is my code:
def setFileModel(self):
self.model = QtGui.QFileSystemModel()
self.folders_lv.setModel(self.model)
self.model.setRootPath(self.directory)
self.folders_lv.setRootIndex(self.model.index(self.directory))
self.folders_lv.expand(self.model.index(self.directory))
self.model.setNameFilters(["*"])
Just hide the columns that you don't want shown:
self.folders_lv.hideColumn(1)
self.folders_lv.hideColumn(2)
(NB: make sure you do this after the model has been initialized).