QGIS plugin hardships

09.09.2008 08:55 ·  Notes  ·  qgis, plugins

I have been struggling with development of the Python plugin for Quantum GIS for quite some time now… I’m adding new features to a polygon layer, but after addition they are not visible on a map and not listed in the layer’s attribute table. However, if I remove the layer from the project and then add it again — all new features are there.

Here is the code I use

geom = QgsGeometry.fromPolygon([lstCoords])
ft = QgsFeature()
ft.setGeometry(geom)
ft.addAttribute(0, QVariant("atribute 1"))
self.iface.getMapCanvas().setCurrentLayer(vLayer)
vLayer.startEditing()
if vLayer.addFeature(ft, True):
    vLayer.commitChanges()
self.iface.getMapCanvas().refresh()

What is the problem? Am I doing something wrong?…

⮜ Prev
Next ⮞