When QStandardItemModel
, which is allocated on the stack, gets destroyed, what happens with objects to which pointers in the model are pointing at (e.g. item
/item2
pointer as in the following example):
QStandardItem* item = new QStandardItem("test");
QStandardItem* item2 = new QStandardItem("test2");
QList<QStandardItem*> list;
list.append(item);
list.append(item2);
QStandardItemModel model;
model.addRow(list);
In this context, if i understood correctly, row in a model is consisted of N values, each value in that row represented as QStandardItem
. This means that "list" object above is one row with two values (columns).
Is this better or worse than using model.setData()
, model.setRowCount()
and manually tracking coordinates?
If full context is needed, it's here. Idea is to manually loop over QSqlQuery
results and fetch rows in chunks. Relevant method is called loadChunk
.
If the model is stack allocated, do i need to somehow manage deallocation of items loaded to model via addRow()
TLDR; how to make sure that model doesn't leak memory when model is stack allocated, but contains a lot of pointers to objects on heap?