[Qt5-feedback] Add internalVariant to QModelIndex

kai.koehne at nokia.com kai.koehne at nokia.com
Tue Jul 19 09:49:55 CEST 2011


Hi,

Nice discussion!

> -----Original Message-----
> From: qt5-feedback-bounces+kai.koehne=nokia.com at qt.nokia.com
> [mailto:qt5-feedback-bounces+kai.koehne=nokia.com at qt.nokia.com] On
> Behalf Of ext Christoph Feck
> Sent: Tuesday, July 12, 2011 2:48 PM
> To: qt5-feedback at qt.nokia.com
> Cc: Nils Jeisecke
> Subject: Re: [Qt5-feedback] Add internalVariant to QModelIndex
> 
> On Tuesday 12 July 2011 13:16:10 Nils Jeisecke wrote:
> > Hi!
> >
> > Currently you can only store either a pointer or a 64bit integer
> > inside a QModelIndex.
> [...]
> > Depending on the data the model is wrapping it can sometimes be quite
> > hard to store all required information in one of those elements.
> 
> 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?

Just wanted to share my use case ...

Kai



More information about the Qt5-feedback mailing list