Reputation: 31
Suppose I have some code like this:
QListWidgetItem *pItem = new QListWidgetItem(...);
insertItem(i, pItem);
.....
then:
removeRows(..)
If I don't delete the pointer pItem
, will it cause memory leak?
Upvotes: 1
Views: 226
Reputation: 4010
From Qt documentation:
If you need to insert a new item into the list at a particular position, then it should be constructed without a parent widget. The insertItem() function should then be used to place it within the list. The list widget will take ownership of the item.
So there is no memory leak.
Upvotes: 1