Hi All, I'm trying to write a short plugin and I've been using the PyConsole to test code snip-its. I'm having trouble deleting a column that I've created in a table (even in the attribute table GUI - the delete column button is inactive even though the add table column is active and the layer is editable). Here's the code I've used to create the column;
import qgis.core import qgis.gui import PyQt4.QtCore import PyQt4.QtGui vlayer = qgis.utils.iface.activeLayer() provider = vlayer.dataProvider() feat = QgsFeature() newField = QgsField("azimuth",QVariant.Double) provider.addAttributes([newField]) newFieldIndex = provider.fieldNameIndex(newField.name()) vlayer.commitChanges() When I try to use the following code to delete the column, the function returns 'false'; provider.deleteAttributes([newFieldIndex]) I had a look at the API and apparently some constant called 'QgsAttributeIds', an 'int', is expected by the deleteAttributes() function. I've tried a few variations of this with no success and according to the API it seems that all the deleteAttributes() function does is to return 'false' (http://www.qgis.org/api/qgsvectordataprovider_8cpp-source.html#l00104). What is the correct Python code to delete a column in the PyConsole? Thanks, Chris
_______________________________________________ Qgis-user mailing list Qgis-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-user