I am using layoutAboutToBeChanged().
Here's what I'm doing. It's PyQt. I have a tree made of TreeItem()s (my node class)
# in subclass of QAbstractItemModel
def recreateTree(self):
self.emit(QtCore.SIGNAL('layoutAboutToBeChanged()'))
self.root = TreeItem(None)
# omitted code to generate the other nodes and add them to root
self.emit(QtCore.SIGNAL('layoutChanged()'))
# in subclass of QAbstractItemModel
def recreateTree(self):
self.emit(QtCore.SIGNAL('layoutAboutToBeChanged()'))
self.root = TreeItem(None)
# omitted code to generate the other nodes and add them to root
self.emit(QtCore.SIGNAL('layoutChanged()'))
To copy to clipboard, switch view to plain text mode
When I reassign self.root, Python automatically deletes the old tree (or should) since there's no other reference to it.
Bookmarks