[Qgis-developer] Update map after adding new feature

Alex Bruy voltron at ua.fm
Wed Jul 9 10:53:16 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 of updating map after adding new features to layer?

P.S.: sorry for my bad English, I'm ukrainian
-- 
View this message in context: http://www.nabble.com/Update-map-after-adding-new-feature-tp18363257p18363257.html
Sent from the qgis-developer mailing list archive at Nabble.com.



More information about the Qgis-developer mailing list