Somachr
Somachr

Reputation: 464

Qt tree view with Pyside

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.

Upvotes: 0

Views: 1979

Answers (1)

Dimitry Ernot
Dimitry Ernot

Reputation: 6584

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()

Upvotes: 3

Related Questions