Friday 25 November 2016

python - Does mapCanvas().refresh() not work in QGIS 2.6?


Before I used the function


qgis.utils.iface.mapCanvas().refresh()

to reload the map canvas after for example a layer color was changed from a plugin. But this is not working with QGIS 2.6 for me. Do I have to use another function to refresh the map canvas or is this a bug?



Answer



It may very well be a bug as I also cannot get the canvas to refresh. You can try the following as a workaround:



myLayer.triggerRepaint()

To refresh all layers following function can be used:


def refresh_layers(self):
for layer in qgis.utils.iface.mapCanvas().layers():
layer.triggerRepaint()

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...