How to display folders and files tree in a qtreeview instead?

Please tell me how to put in the treeView of the folders and files tree from the directory specified in lineEdit?

#!/usr/bin/python
from PyQt5 import QtCore, QtGui, QtWidgets
from form import Ui_MainWindow
import sys

app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()


def lets_go():
 from PyQt5 import QtWidgets
 dir_name = QtWidgets.QFileDialog.getExistingDirectory(
None
 "Select a directory",
QtWidgets.QDir.currentPath(),
 QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontResolveSymlinks
)
print(str(dir_name))
ui.lineEdit.setText(str(dir_name))
 #ul.treeView 


ui.toolButton.clicked.connect(lets_go())
sys.exit(app.exec_())
April 4th 20 at 13:26
0 answer

Find more questions by tags PythonPyQt