In my current program I have a QTreeView that is modeled from QFileSystem as follows:
self.model= QFileSystemModel()
self.model.setRootPath('')
self.model.setFilter(QDir.Dirs | QDir.NoDotAndDotDot | QDir.Files)
self.model.setNameFilters(["*.txt","*.png", "*.zip","*.csv","*.json","*.xml"])
self.model.setNameFilterDisables(False)
self.tree= QTreeView()
this shows the contents of a directory, and it shows me all the zips.
I've also used zipfile to find the contents of all of the zips in said directory as follows:
os.chdir(current_directory)
for file in glob.glob("*.zip"):
zip = zipfile.ZipFile(file)
dict= {file: zip.namelist()}
self.dict_of_zips.update(dict)
I'd like to create children in the treeview for each zip file, and have each child be a content of the zip folder, as to display all of the items in the zip within the viewer.
I'm struggling, as it seems QFileSystemModel isn't meant to have children added and such.
Is the only way around this to create my own tree view and populate it myself? Is there a way to transfer the icons and filters to such a model?