[prev in list] [next in list] [prev in thread] [next in thread] 

List:       qgis-user
Subject:    Re: [Qgis-user] Adding attributes to a layer with "memory" provider
From:       Václav Řehák <rehakv01 () gmail ! com>
Date:       2010-04-21 19:22:28
Message-ID: g2hdc4d9091004211222n8b09ee71ma77d02a7947ea5e8 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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

[Attachment #5 (text/html)]

Ouch, sorry I was wrong, I&#39;ve mistakenly pasted an invalid snippet.<br><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; \
border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

This is how to do it:<br>
<div class="im"><br>
lines = QgsVectorLayer(&quot;LineString&quot;, &quot;temporary_lines&quot;, \
&quot;memory&quot;)<br> </div>pr = lines.dataProvider()<br>
ret = pr.addAttributes( [ QgsField(&quot;label&quot;, QVariant.String) ] )<br>
QgsMapLayerRegistry.instance().addMapLayer(lines)<br></blockquote></div><br>Thank \
you, this code works for me.<br><br>Vaclav<br>



_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic