[Qgis-developer] Update map after adding new feature

Alexander Bruy voltron at ua.fm
Wed Jul 9 10:46:55 EDT 2008


Hi, all!
I'm newbie in Qgis and Python plugin development. I'm attempt to write Python plugin that read some exchange format and create new polygon features in PostGIS vector layer. For inserting features used code:

vLayer = QgsVectorLayer("D:/test",  "test",  "ogr")
ft = QgsFeature()
ft.setGeometry(QgsGeometry.fromPolygon([lstCoords]))
ft.addAttribute(0, QVariant(attr0))
ft.addAttribute(1, QVariant(attr1))
ft.addAttribute(2, QVariant(attr2))
ft.addAttribute(3, QVariant(attr3))
vLayer.addFeature(ft)

lstCoords - is list of QgsPoints; attr0...attr3 - some strings with attributes.
My first problem is: after inserting no feature appear on the map window and no new records in the layer attribute table. But when this layer reloading, new features are visible and accessible. I'm try to use startEditing(), commitChanges(), setModified() and updateExtents() methods of QgsVectorLayer but this don't help. I'm think that I must rerender map after adding new feature...  but I don't understand how to do this. Can anyone give little example how update map after adding new features to layer?

P.S.: sorry for my bad English, I'm ukrainian

-- реклама -----------------------------------------------------------
Новый Chevrolet Aveo уже в Украине! 
http://video.i.ua/user/835678/9877/43665/



More information about the Qgis-developer mailing list