[Development] Role names and Proxy Models

Stephen Kelly stephen.kelly at kdab.com
Tue Jan 17 11:32:43 CET 2012


On Tuesday, January 17, 2012 08:48:29 you wrote:
> 
> Wouldn't that force the model to reset twice? That is, would I not
> have to add beginResetModel / endResetModel around the call to
> setRoleNames?

Yes, true. Also not an unsolvable problem.

In Qt5 it's not so relevant anyway because roleNames is virtual.

> 
> >> My impression is that this did not work correctly with 4.8, but all I
> >> really confirmed was that I got questions for the wrong role numbers.
> >> The core reason for this, is that Qt 4.8 forces the wrong role names
> >> onto the proxy models.
> > 
> > How does it force the wrong role names onto proxy models?
> 
> Force is a strong word, it implies that proxy models need to use the
> role names of the model being proxies, which might be the case for the
> sort filter proxy model, but, imho, not for the identity proxy model.
> 
> >> A virtual method looks handy, makes it possible to do what I want to.
> >> However, the default role name setting in
> >> QAbstractProxyModel::setSourceModel is still present in Qt 5.0.
> >> 
> >> Does it make more sense now? :-)
> > 
> > I'm afraid I don't see why the above setSourceModel implementation
> > wouldn't work.
> 
> I suppose that it can be made to work, but with a change in the policy
> of handling roles combined with a minimal code change, it can be made
> to work better, imho.
> 

I think you'd need to show some kind of minimal maybe incomplete patch and 
some example code showing why it's needed. Preferably using the current Qt5 
API (virtual roleNames()).

Thanks,

-- 
Stephen Kelly <stephen.kelly at kdab.com> | Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120117/5b1af652/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120117/5b1af652/attachment.sig>


More information about the Development mailing list