I'm building a map, with elements like QgsComposerMap of course, but also QgsComposerLabel, QgsComposerLegend ,etc... Each of these elements has a boolean "setBackgroundEnabled" property, to make them white backgrounded or not. But when aggregating these white backgrounded elements in the QgsComposition, we can see gray bands between them, caused by the deepest gray background. And it's printed when saved as image !

As for canvas, ( i mean canvas.setCanvasColor(Qt.white)), is there a way to set the color of the overall QgsComposition background (the deepest one) ?

Is there something like :

comp = QgsComposition(mapRenderer)

By resizing the paper, one can get the white background.

mapRenderer = QgsMapRenderer()
comp = QgsComposition(mapRenderer)
comp.setPaperSize(w,h) #210 and 297 millimeters by default

If w and h are too small (and so the paper) compared to image dimensions, you'll get gray bands as described in my question.

| improve this answer | |

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.