[Qt-interest] QAggregatingProxyModel ?

Stephen Kelly steveire at gmail.com
Thu Jun 24 17:35:47 CEST 2010


Andre Somers wrote:

> On 23-6-2010 17:30, Stephen Kelly wrote:
>>
>> Option 3) Write your own. A potentially non-trivial amount of work and
>> learning if you haven't implemented a proxy model before. Don't subclass
>> QAbstractProxyModel by the way. Subclass QAbstractItemModel instead.
>>
>>    
> Interesting remark.
> Would you care to explain why that is? I was under the impression that
> QAbstractProxyModel (which subclasses QAbstractItemModel itself) was
> meant to work as a base class for proxy models.

It's the base class for proxy models which have one source model. The 
aggregating proxy has multiple source models, so semantically, it's a 
different class. It would be possible to implement mapToSource and 
mapFromSource to mutliplex and map to and from the correct source model, but 
then your are changing the meaning of a virtual method in its 
reimplementation. (sourceModel() == mapFromSource(idx)->model())

> Or is it that the
> standard setup that it provides does not match what you need for an
> aggregating proxy?

The implementation of QAIM that it does provide probably uses sourceModel(). 
What would that return in an aggregating proxy?

QAbstractProxyModel is quite small anyway. It only provides a few new 
virtuals and some trivial forwarding implementations of QAIM API. I plan on 
writing a QAIM subclass which will still have methods called mapFromSource 
and mapToSource, but without inheriting what that means wrt a sourceModel().
 as you get with QAPM.

All the best,

Steve.


> 
> André
> 





More information about the Qt-interest-old mailing list