1

I am trying to programatically change the "Show all labels and features for all layers" option for a layer which display diagrams.

This option doesn't seem to appear in QgsDiagramRendererV2 api. It seems to be related to QgsPalGeometry, but I can't figure how to set that option so that all diagrams are rendered, even overlapping ones.

Can anybody help on that ?


Still no success to turn that option on. I figured out that it is a global option, and found in QGis api the setShowingAllLabels method in the QgsPalLabeling class. This is obviously the one I am looking for, but I couldn't manage to make it work :

pal = self.iface.mapCanvas().mapRenderer().labelingEngine()
pal.setShowingAllLabels(True)
self.iface.mapCanvas().mapRenderer().setLabelingEngine(pal)

This code doesn't have any effects.

1 Answer 1

1

This code is the answer :

myMapRenderer = self.iface.mapCanvas().mapRenderer()
mLBL = QgsPalLabeling()
mLBL.setShowingAllLabels(True)
mLBL.saveEngineSettings()
myMapRenderer.setLabelingEngine(mLBL)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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