I have a QTreeView with an element baseItem which itself contains some children:
baseItem
- child1
- child2
- child3
Now I want to delete all children of this item but not the item itself. My current approach is to call
if (baseItem->hasChildren())
baseItem->removeRows(rowCnt,baseItem->rowCount());
...where rowCnt is the row index number where baseItem is located at. Unfortunately this does work only when baseItem is at rowCnt=0. What could be wrong here? How else should I delete all children of baseItem?
Thanks!
...where rowCnt is the row index number where baseItem is located at.
No, rowCnt is the index in the subtree under the parent. So:
if (baseItem->hasChildren())
baseItem->removeRows(0,baseItem->rowCount());