Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 带有Pyside的Qt树视图_Python_Qt_Treeview_Directory_Pyside - Fatal编程技术网

Python 带有Pyside的Qt树视图

Python 带有Pyside的Qt树视图,python,qt,treeview,directory,pyside,Python,Qt,Treeview,Directory,Pyside,我在程序目录中有两个文件夹。我需要它们显示在树视图中,它们应该是可扩展的。如何定义树视图中的文件夹?如果有人能给我举个简单的例子。我知道文件夹的名称 我正在使用Python 2.7和Win 8。您可以使用QTreeView和QFileSystemModel来实现这一点: model = QFileSystemModel(); model.setRootPath(QDir.currentPath()) tree = QTreeView() tree.setModel(model) tree.set

我在程序目录中有两个文件夹。我需要它们显示在树视图中,它们应该是可扩展的。如何定义树视图中的文件夹?如果有人能给我举个简单的例子。我知道文件夹的名称


我正在使用Python 2.7和Win 8。

您可以使用
QTreeView
QFileSystemModel
来实现这一点:

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

您可以使用
QTreeView
QFileSystemModel

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

您可以使用
QTreeView
QFileSystemModel

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

您可以使用
QTreeView
QFileSystemModel

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


非常感谢。另外,现在我需要禁用“type”和“size”列。对于这些问题,我很抱歉,但我对这个问题非常陌生,时间不多了。请使用
QTreeView.hideColumn()
。现在我看到了我的文件,但我无法打开它们,知道为什么吗?
QDesktopServices.openUrl(QUrl(“path/yourFile.txt”)
应该使用默认应用程序打开文件。我不知道为什么,但我需要在路径中使用“/”,即使在windows上也是如此……但我有未知数量的文件名。我需要在树视图中单击打开它们。可能吗?谢谢。另外,现在我需要禁用“type”和“size”列。对于这些问题,我很抱歉,但我对这个问题非常陌生,时间不多了。请使用
QTreeView.hideColumn()
。现在我看到了我的文件,但我无法打开它们,知道为什么吗?
QDesktopServices.openUrl(QUrl(“path/yourFile.txt”)
应该使用默认应用程序打开文件。我不知道为什么,但我需要在路径中使用“/”,即使在windows上也是如此……但我有未知数量的文件名。我需要在树视图中单击打开它们。可能吗?谢谢。另外,现在我需要禁用“type”和“size”列。对于这些问题,我很抱歉,但我对这个问题非常陌生,时间不多了。请使用
QTreeView.hideColumn()
。现在我看到了我的文件,但我无法打开它们,知道为什么吗?
QDesktopServices.openUrl(QUrl(“path/yourFile.txt”)
应该使用默认应用程序打开文件。我不知道为什么,但我需要在路径中使用“/”,即使在windows上也是如此……但我有未知数量的文件名。我需要在树视图中单击打开它们。可能吗?谢谢。另外,现在我需要禁用“type”和“size”列。对于这些问题,我很抱歉,但我对这个问题非常陌生,时间不多了。请使用
QTreeView.hideColumn()
。现在我看到了我的文件,但我无法打开它们,知道为什么吗?
QDesktopServices.openUrl(QUrl(“path/yourFile.txt”)
应该使用默认应用程序打开文件。我不知道为什么,但我需要在路径中使用“/”,即使在windows上也是如此……但我有未知数量的文件名。我需要在树视图中单击打开它们。可能吗?