4

I want to display a QPolarChart in a QChartView.

I won't add a title or a legend anything else than the QPolarChart. Unfortunately, when I add my chart I have bit empty white space around the QPolarChart.I guess this is the space for the title and or the legend...

Is there a way to reduce this space?

I already used

chart->layout()->setContentsMargins(0, 0, 0, 0);
chart->setBackgroundRoundness(0);

which helped a bit.

I want to reduce the red margins:

image

user7431005
  • 3,899
  • 4
  • 22
  • 49

1 Answers1

6

Seems like you already followed the guidelines from the answers to the related question: How to remove margin from QChartView or QChart

If you are still not satisfied with the result, you can go one step further and use negative values by calling setContentsMargins directly on the chart object:

chart->setContentsMargins(-10, -10, -10, -10);

while keeping your layout object margins at 0 as you were doing already:

chart->layout()->setContentsMargins(0, 0, 0, 0);

I've done this in the past and it always worked fine, although it's a bit of a hack.

Also, the legend takes up some space so don't forget to hide it if you don't need it.

chart->legend()->hide();

This is the result you will get after making these changes:

Polar chart with negative margins

You might try experimenting with negative values other than -10 to get the desired result.

codeaviator
  • 2,545
  • 17
  • 42