This question already has an answer here:
i am trying to iterate over a large list of features and making a screenshot of the selected feature. My problem is that it seems to be a delay between the refreshing of the canvas and the taking of the screenshot. In other words, the screenshot taken does not correspond to feature i but to feature i-1, sometimes i have several identical screenshots. Is it possible to explicitely wait until the rendering is done by the mapCanvas before calling the saveAsImage method?
This is globally the code that i am using to do this task.
for i in range(n): layer.select(i) iface.actionZoomToSelected().trigger() qgis.utils.iface.mapCanvas().zoomScale(1000) iface.mapCanvas().refresh() imgname = '_'.join(['','object',str(i)]) imgname = ''.join([imgname,'.png']) iface.mapCanvas().saveAsImage(imgname)