Как изменить положение осей на графике в QtChart? В строках 30, 31 задавал по-разному Qt enum. Всё кроме Qt::AlignBottom для оси x и Qt::AlignLeft для оси y приводит к ошибке и падению программы.
qc::QChart* MainWindow::create_graphics(const QVector<qc::QLineSeries*>& lines,
const QString& graphics_name,
const axis_params& axis_x,
const axis_params& axis_y,
const QVector<QString>& lines_names
)
{
QChart* chart = new QChart();
chart->setTitle(graphics_name);
foreach(QLineSeries* line, lines)
{
chart->addSeries(line);
}
//Ось Х
auto&[name_x, start_x, fin_x, count_x] = axis_x;
QValueAxis *axisX = new QValueAxis;
axisX->setTickCount(count_x);
axisX->setLabelFormat("%.2f");
axisX->setRange(start_x, fin_x);
axisX->setTitleText(name_x);
//Ось Y
auto&[name_y, start_y, fin_y, count_y] = axis_y;
QValueAxis *axisY = new QValueAxis;
axisY->setLabelFormat("%.2f");
axisY->setTitleText(name_y);
axisY->setTickCount(count_y);
axisY->setRange(start_y, fin_y);
uint32_t line_idx = 0u;
chart->addAxis(axisX, Qt::AlignBottom);
chart->addAxis(axisY, Qt::AlignLeft);
foreach(QLineSeries* line, lines)
{
line->attachAxis(axisX);
line->attachAxis(axisY);
line->setName(lines_names[line_idx]);
//chart->addSeries(line);
++line_idx;
}
chart->legend()->setVisible(true);
return chart;
}