On Jul 20, 2011 11:18 AM, "Andre Somers" <[email protected]> wrote: > > Op 19-7-2011 9:49, [email protected] schreef: > > Can you give us a use case? > > One of my first experiences with QAbstractItemModel was writing a 'AggregateItemModel', which was basically representing several other QAbstractItemModels as child nodes of a common root node. Think about a tree with 'Locations' as root node, and several QFileSystemModel's as child nodes. > > > > What I actually wanted to store in each QModelIndex of the aggregating model was just the QModelIndex of the aggregated model. I couldn't do this however directly in the QModelIndex, which is why I - like others - had to resort to a cache in the aggregating model - an ugly and error-prone way IMO. > > > >>> What do you think, would it be reasonable to add something like > >>> internalVariant to QModelIndex? > > With this I could have stored the QModelIndex of the aggregated model in the QModelIndex of the aggregating model, right?
I just looked up QPersistentModelIndex and I see that's its size is just one pointer. So it must still be possible to store a persistent index in the internal pointer of the qmodelindex. > Eh, no. That would have been the wrong solution. You can not store > QModelIndexes, they are short-lived. Next time you use it, there a good > chance it became invalid. That really should not be an issue as the AggregateItemModel's index is also intended to be shortlived. Kishore
_______________________________________________ Qt5-feedback mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
