[Qt-interest] begin/endInsertRows and underlying data structures
Girish Ramakrishnan
girish at forwardbias.in
Sun May 10 06:42:02 CEST 2009
Hi Emil,
Emil Eriksson wrote:
> Hello!
>
> In its current form, QAbstractItemModel requires beginInsertRows and
> endInsertRows to be called before and after inserting rows. Insertion
> and removal operations for rows and columns This is all fine in some
> cases, but it's not always that the underlying data structure can
> notify the model BEFORE changes. How does one go about implementing
> the model in that case?
You can choose one of below:
1. You can build a 'shadow' model that retroactively updates itself
based on the real model.
2. Currently, one of the main tasks of begin/endInsertRows is to update
persistent indices and emit the signals. If you are willing to lose
selections in your views when things get inserted in the middle, just
use layout(About)ToBeChanged.
It seems to me that the model/view system in
> Qt is a bit overly complicated in some respects.
>
You are not alone :-) Have you seen
http://labs.trolltech.com/blogs/2009/04/07/item-views-next-gen/ ?
Girish
> Grateful for answers,
> Emil Eriksson
More information about the Qt-interest-old
mailing list