Hairo
Hairo

Reputation: 2214

pyqt - QFileSystemModel without subdirectories?

is possible to make a QFileSystemModel in a QTreeWidget only showing folders in a path without their subfolders? also, can i get the folders size (with anything in them) using QFileSystemModel?

this is my code filtering to only folders:

m_index = r"C:/folder"

model = QtGui.QFileSystemModel()
model.setRootPath(m_index)
model.setFilter(QtCore.QDir.Dirs|QtCore.QDir.NoDotAndDotDot)

view = QtGui.QTreeView()
view.setModel(model)
view.setColumnHidden(2, True)
view.setColumnHidden(3, True)
view.setRootIndex(model.index(m_index))

Upvotes: 0

Views: 916

Answers (1)

Hairo
Hairo

Reputation: 2214

Never mind, view.setItemsExpandable(False) did the job...

Upvotes: 1

Related Questions