Hi,
I use Qt 4.3.3 on Windows and I have started to make the "simple Dom Model" from Qt examples and Demo editable. So I have a QTreeView based on a DomModel who inherits from QAbstractItemModel. The Data is an XML File.
I try to remove rows. No problem for datas, after deleting the data and resave it to a new XML file, the data corresponding to the rows has vanished. But the View deletes always the last row of the same parent Index, so Model and View are not in the same state anymore! Here is my code:
Qt Code:
  1. void DomModel::deleteNode(QModelIndex& rCurrentIndex)
  2. {
  3. emit layoutAboutToBeChanged();
  4. beginRemoveRows(rCurrentIndex.parent(), rCurrentIndex.row(), rCurrentIndex.row());
  5. removeRow(rCurrentIndex.row(),rCurrentIndex.parent());
  6. endRemoveRows();
  7. emit layoutChanged();
  8. }
  9. ...
  10. bool DomModel::removeRow(int BeginRow,const QModelIndex& rParentIndex)
  11. {
  12. QModelIndex TypeIndex = rParentIndex.child(BeginRow, TYPE_ARGUMENT);
  13. QModelIndex AttrIndex = rParentIndex.child(BeginRow, ATTRIBUTES_ARGUMENT);
  14. DomItem* pItem = static_cast<DomItem*>(TypeIndex.internalPointer());
  15. QDomNode Node = pItem->node();
  16. QDomNode ParentNode = Node.parentNode();
  17. ParentNode.removeChild(Node);
  18. return true;
  19. }
To copy to clipboard, switch view to plain text mode 
Any ideas?
Thanks