Thanks qgis 2, the Legend Interface (layers dockwidget) now has Update Drawing Order check box on right-click mouse context menu. I think this feature can let user temporally closes rendering, then changes order of layers without no-used rendering.
And how to use PyQGIS control this feature??
Btw, the PyQGIS API iface.legendInterface().moveLayer( layer, group_index )
in qgis, group_index include any layer and group (on top level?), but
in qgis2, group_index just include group
e.g. If the layer/group structure:
--layer1
--group1
--layer2
--layer3
To move layer1 to group 1
in qgis, use qgis.utils.iface.legendInterface().moveLayer( layer1, 1 )
in qgis2, use iface.legendInterface().moveLayer( layer1, 0 )
Edit:
I use moveLayer, but mapCanvas doesn't refresh, even I use mapCanvas.refresh()
iface.legendInterface().moveLayer( iface.activeLayer(), 0) # activeLayer move to top of gruop in layer legend, but mapCanvas doesn't refresh
iface.mapCanvas().refresh() #nothing happened
But I uncheck and then check Update Drawing Order, it works.
How could I refresh mapCanvas after layer moved??
If I can use PyQGIS to uncheck and check Update Drawing Order, it will work.