QListWidget::clear() effect on pointers
I have a small question which I'm asking just to be on the safe side with memory management.
I have added some QListWidgetItems' pointers to a QListWidget (of course after initialising them with a "new" operator). Now the question is, does the function QListWidget::clear() automatically call the operator delete on the pointers added to the list? The documentation was a little bit vague, since it doesn't say that explicitly. I'm confused whether the delete they meant is just remove items from the list.
If the docs are unclear, see the source!
I would say the docs are quite clear here:
bq. "void QListWidget::clear () [slot]":/doc/qt-4.8/qlistwidget.html#clear
Removes all items and selections in the view.
Warning: All items will be permanently deleted.
In that same page:http://developper.qt.nokia.com/doc/qlistwidget.html it is stated:
[quote]The list widget will take ownership of the item.[/quote]
Taking ownership means that the class will manage the life time of the items you set on it. If in doubt, it helps to search for the term ownership on the documentation page.
@Volker: your link does not work for me?
[quote author="Andre" date="1330326445"]
@Volker: your link does not work for me?[/quote]
I missed a leading slash. Fixed now - thanks for pointing out.
I was 90% sure, since I called the delete operator and the program crashed, and now I'm 100% sure.