magland
20th June 2007, 15:23
I've subclassed QAbstractItemModel. Internally I remove some rows from the model, so I use
emit layoutAboutToBeChanged();
... delete my rows ...
emit layoutChanged();
Everything works fine, except sometimes where apparently the QTreeView tries to access one of the internal pointers I have already deleted - then I get a seg fault. I know this is the issue because if I remove the rows but don't delete the internal data, then everything is fine (except for a memory leak of course). It doesn't happen all the time... only when I have recently selected a child of the row I am to delete.
So my question is.... what do I need to do to notify the QTreeView that rows have been removed and internal data has been deleted.
Thanks :)
emit layoutAboutToBeChanged();
... delete my rows ...
emit layoutChanged();
Everything works fine, except sometimes where apparently the QTreeView tries to access one of the internal pointers I have already deleted - then I get a seg fault. I know this is the issue because if I remove the rows but don't delete the internal data, then everything is fine (except for a memory leak of course). It doesn't happen all the time... only when I have recently selected a child of the row I am to delete.
So my question is.... what do I need to do to notify the QTreeView that rows have been removed and internal data has been deleted.
Thanks :)