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

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()

With canvas caching in the mix (python cookbook, note at the end of the 'Modifying Vector Layers' section), I have to do the following to get a dependable refresh after an edit (in my case from within plugin code in QGIS 2.14):

cachingEnabled = self.iface.mapCanvas().isCachingEnabled()

for layer in self.iface.mapCanvas().layers():
    if cachingEnabled:
        layer.setCacheImage(None)
    layer.triggerRepaint()

self.iface.mapCanvas().refresh()

That is, I always call triggerRepaint() on all layers and then call the mapCanvas's refresh() just to be safe. If caching is enabled, I also reset each layer's cache image before triggering that layer's repaint. I don't know if all of this is required, but I do know it appears to work consistently. The API warns that both QgsMapLayer.setCacheImage() and QgsMapLayer.clearCacheImage() are deprecated, but nothing in the documentation or code mentions what alternative is planned.


Side note: I'm still seeing a refresh bug. If I open the python console before a plugin's first layer edit (in the current project at least), then no matter what the plugin does the map won't refresh. If instead I at least wait to open the console until after the first edit then everything seems to be fine. Just something to be aware of if you're trying to get refreshes to work.