Hi,

I'm trying to develope a complex Model with different Proxymodels. The Main-Model is a Tree with different Items based on a ItemBaseClass.
The first Proxymodel is a QSortFilterProxyModel for the tree-Navigation-Widget. This works.

Qt Code:
  1. Tree:
  2. -Item1
  3. ---sub1
  4. ---subsub1
  5. ---subsub2
  6. ---sub2
  7. -Item2
  8. ---sub3
  9.  
  10. Table of sub1:
  11. subsub1-name | subsub1-property
  12. subsub2-name | subsub2-property
To copy to clipboard, switch view to plain text mode 

The second Proxymodel is to show and edit a TreeItem with subElements in a table.
This works a bit. The Elements are shown in the table, but I cannot insert or delete rows.
My problem is that I do not know how to implement the MapToSource/MapFromSource methods..
So here are my simple implementations:
Qt Code:
  1. QModelIndex TFSEditorItemModel::mapFromSource(const QModelIndex &source) const{
  2. return index(source.row(), source.column(), source.parent());
  3. }
  4.  
  5. QModelIndex TFSEditorItemModel::mapToSource(const QModelIndex &proxy) const {
  6. if(!proxy.isValid())
  7. {
  8. return QModelIndex();
  9. }
  10. return sourceModel()->index(proxy.row(), proxy.column(), proxy.parent() ) ;
  11. }
To copy to clipboard, switch view to plain text mode 

If I try to use mapToSource e.g. to insert a row through the sourceModel, I never get a correct sourceIndex. Especally the proxy.parent-Index is not valid, so the sourceModel cannot create a valid Index in the sourcetree.
How can I get an index of the table-root-item from the sourceModel? I have a Pointer to the Item (the tables root-item) but no Index. I think I cannot remember this Index because it can change..?

I hiope you can help me or give a reference to a good example. I tried to find something, but the results did not help me.

greets
david