[Development] Role names and Proxy Models

Stephen Kelly stephen.kelly at kdab.com
Mon Jan 16 09:58:54 CET 2012


Hi Johan, 

Please reply to the list.

On Monday, January 16, 2012 08:22:48 you wrote:
> 2012/1/16 Stephen Kelly <stephen.kelly at kdab.com>:
> > I'm not sure what your actual proposal is?
> 
> My issue is that the role names of a proxy model are taken directly
> from the model being proxied, i.e. the following lines from
> qabstractproxymodel.cpp (around line 135, in
> QAbstractProxyModel::setSourceModel, Qt 4.8):
> 
> ...
>     }
>     d->roleNames = d->model->roleNames();
> }
> ...
> 
> This overrides any attempts to use setRoleNames in a proxymodel, to
> do, for instance, role-name.transformations. 

How so? This works:

MyProxyModel::setSourceModel(...)
{
  // ...
  BaseProxy::setSourceModel(...);
  // ...

  setRoleNames(...);
}


> 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?

> 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.

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/20120116/b4bafd3d/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/20120116/b4bafd3d/attachment.sig>


More information about the Development mailing list