[Qgis-developer] Set QgsVectorLayer.EditType to value map and populate value:description pairs with python

Eric Goddard egoddard1010 at gmail.com
Mon Jan 27 17:39:07 PST 2014


Thanks for the info,  Matthias. I'm using the development version of QGIS
for the relations support.  Looking forward to future updates!

Eric
On Jan 27, 2014 5:40 PM, "Matthias Kuhn" <matthias.kuhn at gmx.ch> wrote:

> Hi Eric,
>
> On Mon 27 Jan 2014 20:21:35 CET, Eric Goddard wrote:
> > Hi all,
> > And this is where I'm stuck. I can't find anything in the API docs
> > about how to set the value-description pairs. Any help would be
> > greatly appreciated!
> >
> > Thanks,
> > Eric
> >
>
> This was working in 1.8, but it's not working in 2.x releases (so far).
> You may have heard of the update to "SIP API v2". Since we did this, Qt
> objects are converted to python objects to make it more natural to use
> for developers. Before that, you could just retrieve the existing
> valuemap and edit it in place, because when you called
> layer.valueMap(idx), you would receive a reference to the map QGIS
> internally works with. However, the new SIP API converts the map you
> receive to a native python dict and creates a copy of it. And if you
> edit this copy, QGIS doesn't realize, that there are changes.
>
> So, in short: If you use 1.8, just edit the map you get back. If you
> use 2.0, I don't think there is a possibility and there won't be one in
> 2.2. However, for 2.4 there will be an update which will make this
> possible again (with a new API).
>
> Regards
> Matthias
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140127/caedec4f/attachment.html>


More information about the Qgis-developer mailing list