문제

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.

도움이 되었습니까?

해결책

You would have to use QTreeView.expand.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top