[Qgis-user] Adding attributes to a layer with "memory" provider

Václav Řehák rehakv01 at gmail.com
Wed Apr 21 12:22:28 PDT 2010


Ouch, sorry I was wrong, I've mistakenly pasted an invalid snippet.

> This is how to do it:
>
> lines = QgsVectorLayer("LineString", "temporary_lines", "memory")
> pr = lines.dataProvider()
> ret = pr.addAttributes( [ QgsField("label", QVariant.String) ] )
> QgsMapLayerRegistry.instance().addMapLayer(lines)
>

Thank you, this code works for me.

Vaclav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20100421/49094538/attachment.html>


More information about the Qgis-user mailing list