[Interest] Models and aborting structural changes

Federico Ferri federico.ferri.it at gmail.com
Wed Jun 3 12:45:23 CEST 2020

On 3 June 2020 at 10:38:30, Jonathan Purol (contact at folling.de) wrote:

Now you might say "why not just have the server emit both a "before" and
a "after" change event for whatever happens.
Yeah, I would love to do that - but with Qt's current setup it just
isn't possible.
What Qt is missing is an `abortInsertRows` function to reset the model's
internal state.
There are many, many things that can go wrong in our setup, even IF the
data was successfully updated. And if we cannot tell Qt to revert the
changes in case such an error occurs we cannot possible use this approach.
The only solution I would see here would be to call
`begin/endResetModel` in case an error occurs, but that sounds like
trying to put a nail into a coffin with a wrecking ball.


why not cache the bulk changes received from server, and only after
observing a complete set of changes you begin updating the Qt model? i.e.
you should first receive a complete bulk of changes from server like
<“before”, “change item i1”, “change item i2”, …, “after”> and only at that
point you can start changing the Qt model by calling beginInsertRows()
followed by other model changing methods and then endInsertRows().

Sorry if I did not understood some part of your problem.


Federico Ferri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200603/2487a40d/attachment.html>

More information about the Interest mailing list