[Interest] Issues with layoutAboutToBeChanged

Etienne Sandré-Chardonnal etienne.sandre at m4x.org
Fri Mar 31 13:06:08 CEST 2017


Dear all,

I have a tree model which is subclassing QAbstractItemModel.

For one specific operation, I need to fully reorganize a complete tree
branch. The whole branch indexes are invalidated, including the top branch
node. This top branch node is generally selected in the corresponding view
when the user triggers the operation, and it should stay selected, despite
the model index which is being invalidated.

I wanted to use layoutAboutToBeChanged for signalling the operation, but
the documentation is not 100% clear on how to use it.

What should I pass as the persistent index list? Is this a persistent index
on the top branch node since all updates will be made under this common
ancestor?

The documentation says "Subclasses should update any persistent model
indexes after emitting layoutAboutToBeChanged()", what does this mean?

   - Is "should" to be interpreted as "must otherwise your program may
   crash and your system may burn"?
   - Do I need to get the model's persistent index list, iterate over all,
   and update all those who are in the modified branch?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170331/d934a6d1/attachment.html>


More information about the Interest mailing list