Hi,

in my plugin I create a layer using the following code:

self.lines = QgsVectorLayer("LineString", "temporary_lines", "memory")
self.lines.startEditing()
field = QgsField("label", QVariant.String)
field.setLength(100)
ret = self.lines.addAttribute(field)
QgsMapLayerRegistry.instance().addMapLayer(self.lines)
self.lines.commitChanges()

However, the field is not added to the layer and "ret" is false. I realized
I am not even able to add the attribute in the GUI using layer Properties
dialog - the Type dropdown in Attributes - Add column window is empty. Is it
bug or a feature that I cannot add attributes to memory layer?

I'm using 1.4.0 on Windows XP.

Thanks for help.

Vaclav
_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to