I have the following function:
def createScreenshots(layer):
counter = 0
for feature in layer.getFeatures():
counter += 1
point = feature.geometry().asPoint()
qgis.utils.iface.mapCanvas().setCenter(point)
qgis.utils.iface.mapCanvas().refreshAllLayers()
qgis.utils.iface.mapCanvas().saveAsImage("D:\\\\m\\testing\\" + str(counter) + ".png")
Screenshots are not in real coordinates, .pgw header is not in right coordinates, therefore resulting png images are shifted.
Question: How to wait for rendering of canvas after setCenter is called?