1

I am using following code from some official example:

        model = QFileSystemModel()
        model.setRootPath(QDir.currentPath())
        view = QTreeView(parent=self);
        view.setModel(model)

I expected it to expand directory structure in the tree view so directory from which my program is run would be displayed. What I get, however, is unexpanded tree starting with file system root. How can I make it right?

I tried using expand, but it didn't help:

        model = QFileSystemModel()
        index = model.index(QDir.currentPath())
        view = QTreeView(parent=self);
        view.setModel(model)
        view.expand(index)

The tree view is still unexpanded.

gruszczy
  • 40,948
  • 31
  • 128
  • 181

1 Answers1

0

You would have to use QTreeView.expand.

OneOfOne
  • 95,033
  • 20
  • 184
  • 185
  • I tried to use expand, but it didn't help. Any idea why? I posted another snippet. – gruszczy Dec 10 '10 at 20:06
  • check recursive_expand in http://stackoverflow.com/questions/4100139/pyqt-qtreeview-want-to-expand-collapse-all-children-and-grandchildren/4208240#4208240 – OneOfOne Dec 11 '10 at 04:25
  • Yeah, I've noticed, that I have to expand recursively every step of the path. Thanks :-) – gruszczy Dec 11 '10 at 21:25