'I can't highlight (style) in the directory I'm using (current). Only apply style in the entire qtreeview

ex image # QTreeView - QFileSystemModel I can't highlight (style) in the directory I'm using (current). Only apply style in the entire qtreeview

self.dirModel = QtWidgets.QFileSystemModel()
self.model = QtWidgets.QFileSystemModel()
self.tree = QtWidgets.QTreeView()
self.listview = QtWidgets.QListView()

path = user_dir 

self.model.setNameFilters(["*.py", "*.trp"])
#self.model.filter()
self.model.setNameFilterDisables(False)
self.model.setRootPath(QtCore.QDir.rootPath())
self.tree.setModel(self.model)
self.tree.setRootIndex(self.model.index(path))
      
self.tree.setStyleSheet("background-color: yellow")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source