The removeRows method of my QSortFilterProxyModel and QAbstractItemModel seem to work. The QTreeView is redrawn and shows the removed rows are missing. However my insertRow method is not updating the QTreeView, however the data structure is correct after the insert is executed.

QSortFilterProxyModel:
Qt Code:
  1. def insertRow(self,parent,data):
  2. self.sourceModel().insertRow(self.mapToSource(parent),data)
  3.  
  4. def removeRows(self,row,count,parent):
  5. self.sourceModel().removeRows(self.mapToSource(parent).row(),1,self.mapToSource(parent))
To copy to clipboard, switch view to plain text mode 

QAbstractItemModel:
Qt Code:
  1. def insertRow(self,index,obj):
  2. self.beginInsertRows(index,0,1)
  3. # get node from index
  4. node = self.getNode(index)
  5.  
  6. # wrap Node object around given Element
  7. new_node = Node(obj,node)
  8.  
  9. # append new element to parent element
  10. node._obj.append(obj)
  11.  
  12. # wrap any children with Node
  13. for child in obj.iterchildren():
  14. Node(child,new_node)
  15.  
  16. self.endInsertRows()
  17. self.rowsInserted.emit(index,0,1)
  18. return True
To copy to clipboard, switch view to plain text mode 

Upon futher investigation I found out that the rowsInserted signal is not being propagated back through the proxy to the view. I connected it manually but it does nothing. I've tried other methods such as emitting dataChanged. Using layoutAboutToBeChanged/layoutChanged and reset result in a seg fault.

Note: The intent of insertRow is to insert a child node of the given index, only one row is required to be inserted. Is this the correct method? (Qt 4.7)

Any help appreciated.