How to remove margin from QChartView or QChart

梦想的初衷 提交于 2019-11-28 21:31:37

Devopia answerd the question in the comments!

In my example above I needed the following 2 lines of code to remove the red part completely:

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

At Qt 5.11 this does not work because the layout() method const (inherited from QGraphicsWidget):

QGraphicsLayout *QGraphicsWidget::layout() const

Furthermore it is not possible to take a copy of this because QGraphicsLayout is a base class.

For me this works:

chart->setMargins(QMargins(0,0,0,0));
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!