QListWidget removing QListWidgetItems and what it does on memory
-
In the "QListWidget Reference":http://qt-project.org/doc/qt-5.0/qtwidgets/qlistwidget.html it is said that when functions like QListWidget::clear and the QListWidget destructor are deleting QListWidgetItems from the memory, but what happens when I call
@QListWidget::removeItemWidget(item);@
The reference doesn't say anything if the QListWigetItem is deleted from memory or just detached from QListWidget. Can you help me in that point to avoid memory leaks or segmentation faults?
lg enforcer
-
I don't use Qt5 but it looks like Qt 4.8 sources says it is not deleted from memory.
-
"removeItemWidget":http://qt-project.org/doc/qt-5.0/qtwidgets/qlistwidget.html#removeItemWidget just remove the widget from item previously set with "setItemWidget":http://qt-project.org/doc/qt-5.0/qtwidgets/qlistwidget.html#setItemWidget and not delete the widget. If you want to remove an item from list, just delete it, or "takeItem":http://qt-project.org/doc/qt-5.0/qtwidgets/qlistwidget.html#takeItem, but then you'll need to manually destroy it