Qt: How to autoexpand parents of a new QTreeView item when using a QSortFilterProxyModel
- by taynaron
I'm making an app wherein the user can add new data to a QTreeModel at any time. The parent under which it gets placed is automatically expanded to show the new item:
self.tree = DiceModel(headers)
self.treeView.setModel(self.tree)
expand_node = self.tree.addRoll()
#addRoll makes a node, adds it, and returns the (parent) note to be expanded
self.treeView.expand(expand_node)
This works as desired. If I add a QSortFilterProxyModel to the mix:
self.tree = DiceModel(headers)
self.sort = DiceSort(self.tree)
self.treeView.setModel(self.sort)
expand_node = self.tree.addRoll()
#addRoll makes a node, adds it, and returns the (parent) note to be expanded
self.treeView.expand(expand_node)
the parent no longer expands. Any idea what I am doing wrong?