beginInsertRows()

Assume that I want to insert some rows into a table model.
The data for the model is held as:
std::vector<ListBitMap> mydata;
If I have 10 items that I might add can I use:
model.beginInsertRows(QModelIndex(), mydata.size(), mydata.size()+10);
and then add between 0 and 10 rows
and then issue endInsertRows(), or do I need to add EXACTLY 10 rows?
Thanks, David

@Perdrix
:) Then don't callbeginInsertRows()
at the start/till you do. Do your processing first to find out in one pass, then do the adding of the rows in a second pass. Or put them into yourmydata
and callbeginInsertRows()
only after you have added them all into your data to let then model know then (I think that's safe for simple case). Or, just callbeginInsertRows()
each time you come up with one row which needs adding. Not sure you'd notice the difference, I think the multiplerows call is just an optimization to e.g. help the viewer know it could allow for a bunch of updates in one go, it's not mandatory and probably irrelevant unless there are a "large" number of total rows/rows to insert.