On 8/23/2013 9:08 AM, Etienne Sandré-Chardonnal wrote: > But... I always wondered why it is necessary to have both signals (one > before and one after) in the underlying mechanism, and what could be > wrong in doing: > > -modify the model underlying data structure by inserting rows- > beginInsertRows() > endInsertRows() > > Instead of the regular: > beginInsertRows() > -modify the model underlying data structure by inserting rows- > endInsertRows() > > It's always better to understand why are things done how they are...
begin/endInsertRows/Columns tells the view that you are about to change the model. Views can then "wait" to refresh or build their internal data structures until the rows/columns have been inserted in the model. Since view updates could be expensive, this is a useful optimization. If you're doing a lot of complex model updates, such as inserting/deleting lots of rows you could always just call modelReset(), but depending on the view that may cause the view to scroll back to the top. _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest