Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QtCharts axisX() deprecated

Tags:

qt

My code uses QtCharts.

this has - even in the latest docs - the method axisX() I use this for

chart->axisX()->setRange(0, data.size());
chart->axisY()->setRange(0, max);

However with Qt 5.12 I get this message

warning: 'QtCharts::QAbstractAxis* QtCharts::QChart::axisY(QtCharts::QAbstractSeries*) const' is deprecated

How am I supposed to replace the code with something not deprecated?

like image 892
Matthias Pospiech Avatar asked Dec 17 '18 09:12

Matthias Pospiech


1 Answers

Indeed, the mentioned functions are marked as deprecated in the Qt source code:

Q_DECL_DEPRECATED QAbstractAxis *axisX(QAbstractSeries *series = nullptr) const;
Q_DECL_DEPRECATED QAbstractAxis *axisY(QAbstractSeries *series = nullptr) const;

I think you have to use the following function instead:

QList<QAbstractAxis*> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical,
                           QAbstractSeries *series = nullptr) const;

I.e.

auto xAxis = chart->axes(Qt::Horizontal);
auto yAxis = chart->axes(Qt::Vertical);
[..]
like image 187
vahancho Avatar answered Nov 16 '22 23:11

vahancho