我正在尝试将QtCharts与图表中心的X轴和Y轴一起使用。
因此,中心点将位于我的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