我正在尝试在图表中心使用带有 X 轴和 Y 轴的 QtCharts。
因此,中心点将位于我的 QtChart 的中间......有将轴对齐到顶部/底部或左/右(addAxis(QValueAxis*,Qt::AlignTop)
)的选项。但是,没有选项可以将其对齐到中心。当我AlignCenter
用作addAxis
参数时,我得到一个错误。
有什么帮助吗?
坦克。
编辑(提供代码和错误):
QChart *BScopeChart = new QChart();
QLineSeries *BScopeSerie = new QLineSeries(this);
BScopeChart->setMargins(QMargins(0, 0, 0, 0));
QValueAxis *BScopeAxisX = new QValueAxis;
BScopeAxisX->setRange(-50, 50);
QValueAxis *BScopeAxisY = new QValueAxis;
BScopeAxisY->setRange(-5, 5);
BScopeChart->addAxis(BScopeAxisY, Qt::AlignLeft); // I need this Line change to something like: BScopeChart->addAxis(BScopeAxisY, Qt::AlignCenter)
BScopeChart->addAxis(BScopeAxisX, Qt::AlignBottom); // I need this Line change to something like: BScopeChart->addAxis(BScopeAxisX, Qt::AlignCenter);
ui.widgetBScopeQChart->setChart(BScopeChart);
当我将这两行更改为:
BScopeChart->addAxis(BScopeAxisY, Qt::AlignCenter);
BScopeChart->addAxis(BScopeAxisX, Qt::AlignCenter);
我面临这个错误: ErrorScreenshot