JiageWang / opencv-pyqt5

使用opencv与pyqt5实现的图像处理程序,已实现转灰度图、图像平滑、形态学操作、梯度计算、阈值处理、边缘检测、轮廓检测
351 stars 73 forks source link

Rootpath of FilesystemTreeview seems not work #1

Open QiangZiBro opened 4 years ago

QiangZiBro commented 4 years ago

Hi, bro, nice work! I find that QFileSystemModel.setRootPath seems not to work in PyQt5, so I modified some codes according to this and it works now origin code

        self.fileSystemModel = QFileSystemModel()
        self.fileSystemModel.setRootPath('.')
        self.setModel(self.fileSystemModel)

modified

        # 设置根目录
        self.fileSystemModel = QFileSystemModel()  # 1
        self.setModel(self.fileSystemModel)  # 2
        self.fileSystemModel.setRootPath(QDir.rootPath())  # 3
        self.setRootIndex(self.fileSystemModel.index("/Users/mac/Pictures"))  # 4
JiageWang commented 4 years ago

Hi, bro, nice work! I find that QFileSystemModel.setRootPath seems not to work in PyQt5, so I modified some codes according to this and it works now origin code

        self.fileSystemModel = QFileSystemModel()
        self.fileSystemModel.setRootPath('.')
        self.setModel(self.fileSystemModel)

modified

        # 设置根目录
        self.fileSystemModel = QFileSystemModel()  # 1
        self.setModel(self.fileSystemModel)  # 2
        self.fileSystemModel.setRootPath(QDir.rootPath())  # 3
        self.setRootIndex(self.fileSystemModel.index("/Users/mac/Pictures"))  # 4

感谢指正!摸索学习中