[Qgis-developer] Add attributes to memory provider with python

Martin Dobias wonder.sk at gmail.com
Thu Mar 3 17:49:11 EST 2011


On Mon, Feb 28, 2011 at 1:50 PM, Ziegler Stefan <Stefan.Ziegler at bd.so.ch> wrote:
> Hi
> I'm trying to add some attributes to a memory provider but with no luck. I
> pasted the code from the cookbook [1] into the python console. The layer
> with the feature is added but there are no attributes in the layer. Did I
> miss something? Has something changed?

It seems that the semantics has slightly changed recently with the
merge of table join branch. Now the fields are stored in the layer
when the layer is created, so when the provider adds new fields in the
meantime, they're not propagated automatically to the layer. You have
to call explicitly:
layer.updateFieldMap()

Probably this could be considered as a bug.

Martin


More information about the Qgis-developer mailing list