/qt_treeview.py Secret
Created
December 29, 2021 22:23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
import sys | |
from PySide6.QtCore import QDir | |
from PySide6.QtWidgets import ( | |
QApplication, | |
QFileSystemModel, | |
QMainWindow, | |
QTreeView, | |
) | |
class Example(QMainWindow): | |
def __init__(self): | |
super().__init__() | |
self.init_ui() | |
self.setWindowTitle('TreeView') | |
def init_ui(self): | |
tree = QTreeView() | |
self.setCentralWidget(tree) | |
model = QFileSystemModel() | |
model.setRootPath(QDir.currentPath()) | |
tree.setModel(model) | |
def main(): | |
app = QApplication(sys.argv) | |
ex = Example() | |
ex.show() | |
sys.exit(app.exec()) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment