[Qgis-developer] Update map after adding new feature

Alex Bruy voltron at ua.fm
Fri Jul 11 10:01:00 EDT 2008


Many thanks for replies, Carson and Martin.
I'm try do add code that refresh map canvas, but this don't help.  Layer
manually added to TOC. I'll tested plugin on both types of vector layers
(PostGIS and shapefile) and have no result - features don't appears and
attribute table still empty... Only after layer reloading all becomes ok.
Maybe, I'm do something wrong? My last code is:

mc = self.iface.getMapCanvas()
vLayer = QgsVectorLayer('D:/test', 'test', 'ogr')
#vLayer = QgsVectorLayer('dbname='geobase' host=127.0.0.1 port=5432
user='postgres' table="public"."proba" (the_geom) sql=', 'test', 'postgres')
fet = QgsFeature()
fet.setGeometry(QgsGeometry.fromPolygon([lstCoords]))
fet.addAttribute(0, QVariant(attr0))
fet.addAttribute(1, QVariant(attr1))
fet.addAttribute(2, QVariant(attr2))
fet.addAttribute(3, QVariant(attr3))
vLayer.startEditing()
if vLayer.addFeature(fet, True):
	vLayer.commitChanges()
	vLayer.setModified()
        vLayer.updateExtents()
	mc.refresh()

-- 
View this message in context: http://www.nabble.com/Update-map-after-adding-new-feature-tp18363257p18404548.html
Sent from the qgis-developer mailing list archive at Nabble.com.



More information about the Qgis-developer mailing list