[Qgis-developer] problem with feature request and updateFeature

Matthias Kuhn matthias.kuhn at gmx.ch
Fri Mar 22 09:22:22 PDT 2013


Hi Denis,

On 22.03.2013 14:43, Denis Rouzaud wrote:
> Hi Matthias,
>
> Thanks for your reply.
> This should work better, the loop is not exited.
>
> However, my field values are set to NULL using either
> changeAttributeValue(s) on vector layer or on data provider.
>
> I tried:
>
> vectorLayer.changeAttributeValue( f.id(), fieldIdx, QVariant(alt) )
>
> vectorLayer.dataProvider().changeAttributeValues( {f.id(): {fieldIdx:
> QVariant(alt)}} )
>
> Both return true, but changes are not written. I also tried without
> transforming the values to QVariant.
>
> Do you have any hint?
>
> Thanks,
>
> Denis
>

I tried to reproduce this, but vectorLayer.changeAttributeValue( id,
idx, value ) works for me for integer and string fields (without
converting them to QVariant manually, but that should not hurt). The
only thing that happened was, that when I tried to set an integer field
to a random string value, it was set to 0 instead.
I had an attribute table window open to verify, which updated the
changes immediately.

Sorry,

Matthias


More information about the Qgis-developer mailing list