No, still crash with message "ASSERT failure in QList<T>::at: "index out of range"". What am I doing wrong? Crash appears even I'm trying to clear treeWidget and load data in it again, not just on item deleting.
No, still crash with message "ASSERT failure in QList<T>::at: "index out of range"". What am I doing wrong? Crash appears even I'm trying to clear treeWidget and load data in it again, not just on item deleting.
Then the problem is with foreach. Most likely, as you delete the list items, the indexing of items (crashing is QTreeWidget::at()) becomes invalid. I suggest while and using QList::takeFirst() as a more sure processing the list. takeFirst() removes the first item from the list and returns it (or it returns nullptr if the list is empty).
xsid (29th December 2014)
The problem was not in code. Every solutions above works. In the widget properties MUST be set selectionBehavior->SelectRows (I guess in case of multiple columns such mine case). Thank you, Radek, your code is very usefull and thanks for clarification about how to delete TreeWidget item correctly!
Last edited by xsid; 29th December 2014 at 21:18.
Bookmarks