i am trying to make a QGIS plugin ready for the new QGIS API in the current development branch (for the upcoming QGIS 2.0 release).
However i struggle a bit on how to add new attributes to the attribute table.
Up to now i have added new attributes like this:
# Working in QGIS Lisboa layer = ... # QGsVectorLayer object name = "newAttribute" provider = layer.dataProvider() caps = provider.capabilities() # Check if attribute is already there, return "-1" if not ind = provider.fieldNameIndex(name) try: if ind == -1: if caps & QgsVectorDataProvider.AddAttributes: res = provider.addAttributes( [ QgsField(name,double) ] ) except: return False
In the recent QGIS dev. version these steps aren't working anymore (the attribute column isn't added) and i was not able to find the solution in the above mentioned wiki-page.
Can someone give me hint?