0

How do i limit the path of a treeview on PyQt5? Below is my code and i want to limit the path to C:\My Stuff\Movies To show folders and files inside that directory. Also how to i set what formats it can show such as .avi and .mp4?

    self.treeView = QtWidgets.QTreeView(self.centralWidget)
    self.treeView.setSortingEnabled(True)
    self.treeView.setObjectName("treeView")
    self.horizontalLayout_4.addWidget(self.treeView)

    self.file_model=QtWidgets.QFileSystemModel()
    self.file_model.setRootPath('C:\My Stuff\Movies')
    self.treeView.setModel(self.file_model)
    self.treeView.setHeaderHidden(True)
    self.treeView.hideColumn(1)
    self.treeView.hideColumn(2)
    self.treeView.hideColumn(3)
L.John.B
  • 120
  • 1
  • 13
  • 1
    For your first question, the answer on this post may help you out: [Python PyQt QFileSystemModel Root Path](http://stackoverflow.com/questions/19948159/python-pyqt-qfilesystemmodel-root-path) – chickity china chinese chicken Jul 07 '16 at 01:29
  • Although it's in c++, the Q&A in this post may help for filtering by filetypes: [one type of file format in QTreeView](http://stackoverflow.com/questions/4719179/one-type-of-file-format-in-qtreeview) – chickity china chinese chicken Jul 07 '16 at 01:32
  • @downshift perfect, thanks heaps. I tried searching on here but nothing came up. Thanks for the links. – L.John.B Jul 07 '16 at 05:14

0 Answers0