Hi Giovanni, Thanks for the tip. To answer your question: I am trying to synchronise the layer with the datasource. Having said that, I don't seem to be able to get 'reload' to work. It looks like reload is reimplemented in QgsVectorLayer, which in turns calls the dataProvider's reloadData method, so this may vary by provider type? I tried it with a shapefile and a spatialite layer, and it did not seem to do anything: I deleted several fields from the shapefile and added a field to the spatialite layer in an external program, and these changes were not reflected when I 'reloaded' the layers. Am I missing something here? Perhaps there is something else needed to get the changes to 'show up'?
Cheers, Carson On Wed, May 16, 2012 at 4:36 PM, G. Allegri <[email protected]> wrote: > Do you mean refresh the rendering or synchronizing the layer with the data > source? > I usually use QgsMapLayer::reload() for the latter, and > QgsMapCanvas::refresh() for the first. > > giovanni > > 2012/5/16 Carson Farmer <[email protected]> >> >> Hi list, does anyone know of a clever way to (programmatically) reload >> a layer without actually removing it and re-adding it to the layer >> list. Some context: I have a layer that sometimes gets updated by an >> external application, and I want to be able to 'refresh' the layer >> from the Python console to reflect these changes (new features, >> deleted features, new attributes, etc.). I *could* simply load the >> layer again, but I'm hoping there is a more efficient way to do this >> (also I want to keep the current styling, layer order, unique layer >> id, etc). >> >> Any thoughts/ideas? Note: assume we are working with a spatialite layer >> for now. >> >> Carson >> >> -- >> Dr. Carson J. Q. Farmer >> Centre for GeoInformatics (CGI) >> School of Geography and Geosciences >> Irvine Building, University of St Andrews >> St Andrews, Fife, KY16 9AL >> Scotland, UK >> _______________________________________________ >> Qgis-developer mailing list >> [email protected] >> http://lists.osgeo.org/mailman/listinfo/qgis-developer > > -- Dr. Carson J. Q. Farmer Centre for GeoInformatics (CGI) School of Geography and Geosciences Irvine Building, University of St Andrews St Andrews, Fife, KY16 9AL Scotland, UK _______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
