Consequences for calling beginInsertRows() and endInsertRosw() an once?
-
Hey all,
I asked this question on stack overflow sometime ago but did not get and answer:[https://stackoverflow.com/q/70962488/10231906](link url)
The Qt documanetation is very clear that you should sandwich your data changes between beginInsertRows()/endInsertRows() or beginResetModel()/endResetModel() etc. My issue here is that I'm having to significantly compromise the simplicity of the design to accomodate this requirement. Are there really serious negative consequence for doing this:
change_data(); beginInsertRows(); endInsertRows();instead of this:
beginInsertRows(); change_data(); endInsertRows();I have tried the latter before and everything compiled and ran just fine. Just trying to get a sence for how crucial this really is. Thanks for your help.
-
Your first code will most likely kill your view sooner or later, esp. when you have selections, item widgets and insert somewhere in between since beginInsertRows() expects that the model contains the old row count and endInsertRows() sees the new row count in the model.