PyQt的:在QFileSystemModel
问题描述:
当前目录下我使用下面的代码从一些官方例子:PyQt的:在QFileSystemModel
model = QFileSystemModel()
model.setRootPath(QDir.currentPath())
view = QTreeView(parent=self);
view.setModel(model)
我预计它在树视图中展开目录结构,所以从我的程序运行将显示目录。然而,我得到的是从文件系统根开始的未扩展树。我怎样才能做到这一点?
我试着用expand
,但它并没有帮助:
model = QFileSystemModel()
index = model.index(QDir.currentPath())
view = QTreeView(parent=self);
view.setModel(model)
view.expand(index)
树状视图仍然未膨胀。
我试图使用扩展,但它没有帮助。任何想法为什么?我发布了另一个片段。 – gruszczy 2010-12-10 20:06:19
检查recursive_expand在http://*.com/questions/4100139/pyqt-qtreeview-want-to-expand-collapse-all-children-and-grandchildren/4208240#4208240 – OneOfOne 2010-12-11 04:25:17
是的,我注意到,我有递归地扩展路径的每一步。谢谢 :-) – gruszczy 2010-12-11 21:25:53