Hello,
i have a problem updating my view (QAbtractItemView) when i change the root item in the model (QAbtractItemModel).

My data forms a tree with some branches serving as RootItems in the model. If I now change the RootItem, the view is not updated. Only if the value of a parameter changes and it emits a signal, that parameter is updated in the view.
If the RootItem changes, I call dataChanged(), which does nothing. I have also called resetInternalData(), which doesn't help either.

DataTree.PNG

Here is my method where I change the RootItem.

Qt Code:
  1. void TileContentBaseModel::setRootItem(BaseItem * rootItem)
  2. {
  3. if (RootItem != rootItem)
  4. {
  5. beginResetModel();
  6. if (RootItem)
  7. {
  8. disconnect(RootItem, SIGNAL(changedValue(BaseItem*)), this, SLOT(updateValue(BaseItem*)));
  9. }
  10.  
  11. RootItem = rootItem;
  12.  
  13. if (RootItem)
  14. {
  15. connect(RootItem, SIGNAL(changedValue(BaseItem*)), this, SLOT(updateValue(BaseItem*)));
  16. }
  17. endResetModel();
  18.  
  19. QModelIndex index1 = index(0,0, QModelIndex());
  20. QModelIndex index2 = index(rowCount()-1,columnCount()-1, QModelIndex());
  21.  
  22. emit dataChanged(index1,
  23. index2,
  24. QVector<int>()
  25. << Qt::DisplayRole
  26. << Qt::TextColorRole);
  27. }
  28. }
To copy to clipboard, switch view to plain text mode 

I am grateful for any advice.