Hi
i dont know why im get into trouble with removing all rows and sub rows from qtreeview
im using QStandardItemModel as the model . now here is my code that doesn't work .


Qt Code:
  1. QModelIndex FirstQModelIndex;
  2. QModelIndex parentQModelIndex;
  3. int iMdlChidCound = m_model->hasChildren();
  4. if(iMdlChidCound > 0)
  5. {
  6. // only if there at list 1 row in the view
  7. FirstQModelIndex = m_model->item(0,0)->index();
  8. QStandardItem* feedItem = m_model->itemFromIndex(FirstQModelIndex);
  9. // get the parent of the first row its the header row
  10. QStandardItem* parentItem = feedItem->parent();
  11.  
  12.  
  13. // here im getting exception
  14. int parent_rows= parentItem->hasChildren();
  15. parentQModelIndex = m_model->indexFromItem(parentItem);
  16.  
  17.  
  18. // now i like to delete all the rows under the header , and its dosnt work
  19. if(parent_rows>0)
  20. {
  21. bool b = feedItem->model()->removeRows(0,y,parentQModelIndex);
  22. }
  23. }
To copy to clipboard, switch view to plain text mode