QStandardItemModel item ownership
-
Sill question but I found documentation unclear or can't deduce if it is stated there somewhere:
I have a model with items and so on. Now, I'd like to remove all the items usingsetRowCount(0);
- will memory be released for all QStandardItem* entries properly or do I need to iterate and delete them? (Qt 6.2.3)Thanks in advance.
Artur. -
@artwaw said in QStandardItemModel item ownership:
Sill question but I found documentation unclear or can't deduce if it is stated there somewhere:
I have a model with items and so on. Now, I'd like to remove all the items usingsetRowCount(0);
- will memory be released for all QStandardItem* entries properly or do I need to iterate and delete them? (Qt 6.2.3)Not a silly question at all! I didn't know the answer either so I went digging.
Looks like the old QStandardItems are deleted: https://code.woboq.org/qt6/qtbase/src/gui/itemmodels/qstandarditemmodel.cpp.html#_ZN13QStandardItem10removeRowsEii
-
But it's in the documentation for e.g. setItem(): The model takes ownership of the item.