Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rootpath of FilesystemTreeview seems not work #1

Open
QiangZiBro opened this issue Mar 14, 2020 · 1 comment
Open

Rootpath of FilesystemTreeview seems not work #1

QiangZiBro opened this issue Mar 14, 2020 · 1 comment

Comments

@QiangZiBro
Copy link

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
Copy link
Owner

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

感谢指正!摸索学习中

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants