Qt tree view with Pyside

冷暖自知 提交于 2019-12-13 04:42:34

问题


I have two folders in program directory. I need them to show in tree view, they should be expandable. How can I define what folder will be in tree view? If anyone canshow me an easy example. I know names of folders.

I´m using Python 2.7 and Win 8.


回答1:


You can do that with QTreeView and QFileSystemModel:

model = QFileSystemModel();
model.setRootPath(QDir.currentPath())
tree = QTreeView()
tree.setModel(model)
tree.setRootIndex(model.index(QDir.currentPath()))
tree.show()


来源:https://stackoverflow.com/questions/20472746/qt-tree-view-with-pyside

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!