QSortFilterProxyModel - refresh TreeNode on delete/add
I have developed a model based on QSortFilterProxyModel and so far it works well. I have an option called 'Refresh Folder' in Contextmenu of the QTreeView.
Refresh Folder- needs to updates the parent TreeNode with newly added child Nodes (reading from the disk at particular location).
When i filter nodes based on some regular expression it displays desired Nodes. In the mean while i want to refresh/Reload/update the folder node if there are any new files exists at parent directory then i have to update the Parent TreeNode and filter it again as user typed filtered text.
But in my case , When the user tries to refresh a Parent TreeNode when it is in filtered mode TreeView displays duplicate Nodes.How to solve this?/////
Note: QTreView allows Updates/Refresh/Reload a perticular Folder Node properly when there is no filtered text
How to update/Refresh a Folder TreeNode when Filter is on?
I am currently not sure, where the bug could be located.
Can you show us some of your code, especially the model and the QSPPM you have?
In my 'RefreshFolder' method inside treeview class which inherits QTreeView and here is the code.
please let me know if you need more info.
data=self.getData(index) # returns custom data with
""" here i am reading files from disk and updating the item"""
self.setupModelData(files,item)#---adds file to parent-item
I think i found the problem let me solve and let you know.
problem was with ---model.removeRows(0,item.rowCount(),index)
solution -- item.removeRows(0,item.rowCount())