View Full Version : beginInsertRows() after adding new data
UVV
18th November 2010, 19:00
Hi,
The Assistant says that
...you must call this function before inserting data into the model's underlying data store
But I firstly add data and then do:
beginInsertRows(parent, row, row + count - 1);
endInsertRows();
That is because I don't know count before the data is being added.
Will it have any unnecessary consequences?
JuanMO
18th November 2010, 19:16
Hi,
what you need is
beginInsertRows(parent, row, row + count - 1)
// update the rows you need
endInsertRows();
this avoid the views to access that data in the middle of the change
UVV
18th November 2010, 19:19
Hi,
what you need is
beginInsertRows(parent, row, row + count - 1)
// update the rows you need
endInsertRows();
this avoid the views to access that data in the middle of the change
The key point is that I do not know beforehand how many rows would be inserted.
dw
18th November 2010, 21:33
I had the same situation, and I did that. It works.
As far as I understand the implementation of beginInsertRows and endInsertRows it doesn't really matter unless you want to use the rowsAboutToBeInserted signal.
JuanMO
18th November 2010, 21:54
If the Model change drastically you can use
beginResetModel()
// changes
endResetModel()
those pair of method "Lock the Model" during you change it
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.