You do double-delete your items.
On line 16 of the first code snippet, you add item[qIndex] to the list widget. When calling QListWidget::clear() (or when the widget is destroyed), the item at this memory address is deleted. Since it was not allocated on the heap but (presumably) on the stack or as a global variable in line 1 of the second code snippet, the underlying code to free() reports a corruption.
This is easy to fix: allocate the items on the heap (with new) and let the list widget delete them when appropriate.
Bookmarks