2

When I change symbology for a given QgsVectorLayer (QGIS 2.14.16 LTR) by

r=iface.activeLayer().rendererV2()
r.symbol().symbolLayers()[0].setColor(0,0,255,255)

as shown here:

enter image description here

and refreshing the map content by

iface.mapCanvas().refreshAllLayers()

I get the expected result, but the Layer Tree does not update as shown here:

enter image description here

What am I missing, and how can I update the Layer tree from PyQGIS programmatically?

2

Tell the layer tree view to refresh your layer's symbology:

iface.layerTreeView().refreshLayerSymbology( iface.activeLayer().id() )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.