Qt: How to autoexpand parents of a new QTreeView item when using a QSortFilterProxyModel

Posted by taynaron on Stack Overflow See other posts from Stack Overflow or by taynaron
Published on 2010-04-17T05:30:22Z Indexed on 2010/04/17 5:33 UTC
Read the original article Hit count: 226

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about python

Related posts about pyqt