How to abort beginInsertRows()?

  • I've got a tree model + view and I'm dragging and dropping to my hearts content.
    Even the shift key works as a "move" operation.

    The problem is that the underlying data source is a disk file with some hard constraints as to its size, so one day soon I'll call beginInsertRows, try to insert the rows and it will fail.

    Am I missing something? There isn't an abortInsertRows() that I can see.
    Also, it's not clear whether I can call beginResetModel() before endInsertRows().

    I'm using "ModelTest": after inserting
    @#undef QVERIFY
    #define QVERIFY Q_ASSERT

    I can use it in a regular application - it's happy, so I think I've gone as far as I can without a definitive answer.

  • Had the same problem some time ago and it seems a corresponding abortInsertRows (which would also need to signal to the views) was just forgotten. I "fixed" it by doing the operations that could fail before signaling anything, in a buffer so to say, and when it succeeded finally called beginInsertRows, inserted the buffer into the model and finished normally with endInsertRows.

  • IIRC there are no abort messages for any beginXXX endXXX functions. The idea is if you start inserting, you should also finish it. The other option is to use endXXXa dn reset (with the side effect of trees being closed ;-( ).

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.