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):
  imgname = '_'.join(['','object',str(i)])
  imgname = ''.join([imgname,'.png'])
  • have you tried the Atlas functionality in the map composer? That effectively does the same thing, and you get more control over the cartography. Tutorial can be found here
    – Steven Kay
    Jul 21, 2015 at 15:13
  • 2
    Not sure of my answer but ... did u try to paste your "capture code" in the mapCanvasRefreshed() signal of the MapCanvas ? Tell me if it helps ...
    – Snaileater
    Jul 21, 2015 at 19:34
  • @snaileater i already tried that but qgis freezes. Jul 22, 2015 at 15:55
  • @StevenKay i didn't know about this feature, i will check it out. As a temporary solution i used an older version of qgis in which my actual code seems to work as i expect. Jul 22, 2015 at 15:56


Browse other questions tagged or ask your own question.