summaryrefslogtreecommitdiffstats
path: root/examples/charts/chartthemes
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2018-04-24 12:32:17 +0200
committerMichal Klocek <michal.klocek@qt.io>2018-04-30 13:59:23 +0000
commitd3ea72e28ca82640e50900d42bf0c9ee76aa7f95 (patch)
tree1d72276672b2ef7b1ac76e77283f31d45530cb3c /examples/charts/chartthemes
parent8b4ad5a108b53e6964815856b37cf004099ce505 (diff)
Add proper 'deprecated' warnings
Use Q_DECL_DEPRECATED to mark deprecated API. Fix examples to do not use deprecated functions. These functions were 'marked' as deprecated when multiple axes were introduced. Moreover, axis X/Y is an ambiguous term and not necessary mean Horizontal/Vertical axis. These deprecated methods also create an issue when given series should be attached to several Horizonal/ Vertical axes and calling them can cause unwanted results. Change-Id: I639e1b964240b80c2b3b93b74b061da324bca1ff Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'examples/charts/chartthemes')
-rw-r--r--examples/charts/chartthemes/themewidget.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/examples/charts/chartthemes/themewidget.cpp b/examples/charts/chartthemes/themewidget.cpp
index 84ea8231..cbcdb5c9 100644
--- a/examples/charts/chartthemes/themewidget.cpp
+++ b/examples/charts/chartthemes/themewidget.cpp
@@ -198,10 +198,12 @@ QChart *ThemeWidget::createAreaChart() const
}
chart->createDefaultAxes();
- chart->axisX()->setRange(0, m_valueCount - 1);
- chart->axisY()->setRange(0, m_valueMax);
+ chart->axes(Qt::Horizontal).first()->setRange(0, m_valueCount - 1);
+ chart->axes(Qt::Vertical).first()->setRange(0, m_valueMax);
// Add space to label to add space between labels and axis
- static_cast<QValueAxis *>(chart->axisY())->setLabelFormat("%.1f ");
+ QValueAxis *axisY = qobject_cast<QValueAxis*>(chart->axes(Qt::Vertical).first());
+ Q_ASSERT(axisY);
+ axisY->setLabelFormat("%.1f ");
return chart;
}
@@ -222,9 +224,11 @@ QChart *ThemeWidget::createBarChart(int valueCount) const
chart->addSeries(series);
chart->createDefaultAxes();
- chart->axisY()->setRange(0, m_valueMax * 2);
+ chart->axes(Qt::Vertical).first()->setRange(0, m_valueMax * 2);
// Add space to label to add space between labels and axis
- static_cast<QValueAxis *>(chart->axisY())->setLabelFormat("%.1f ");
+ QValueAxis *axisY = qobject_cast<QValueAxis*>(chart->axes(Qt::Vertical).first());
+ Q_ASSERT(axisY);
+ axisY->setLabelFormat("%.1f ");
return chart;
}
@@ -251,12 +255,14 @@ QChart *ThemeWidget::createLineChart() const
//![3]
chart->createDefaultAxes();
- chart->axisX()->setRange(0, m_valueMax);
- chart->axisY()->setRange(0, m_valueCount);
+ chart->axes(Qt::Horizontal).first()->setRange(0, m_valueMax);
+ chart->axes(Qt::Vertical).first()->setRange(0, m_valueCount);
//![3]
//![4]
// Add space to label to add space between labels and axis
- static_cast<QValueAxis *>(chart->axisY())->setLabelFormat("%.1f ");
+ QValueAxis *axisY = qobject_cast<QValueAxis*>(chart->axes(Qt::Vertical).first());
+ Q_ASSERT(axisY);
+ axisY->setLabelFormat("%.1f ");
//![4]
return chart;
@@ -299,11 +305,13 @@ QChart *ThemeWidget::createSplineChart() const
}
chart->createDefaultAxes();
- chart->axisX()->setRange(0, m_valueMax);
- chart->axisY()->setRange(0, m_valueCount);
- // Add space to label to add space between labels and axis
- static_cast<QValueAxis *>(chart->axisY())->setLabelFormat("%.1f ");
+ chart->axes(Qt::Horizontal).first()->setRange(0, m_valueMax);
+ chart->axes(Qt::Vertical).first()->setRange(0, m_valueCount);
+ // Add space to label to add space between labels and axis
+ QValueAxis *axisY = qobject_cast<QValueAxis*>(chart->axes(Qt::Vertical).first());
+ Q_ASSERT(axisY);
+ axisY->setLabelFormat("%.1f ");
return chart;
}
@@ -324,11 +332,12 @@ QChart *ThemeWidget::createScatterChart() const
}
chart->createDefaultAxes();
- chart->axisX()->setRange(0, m_valueMax);
- chart->axisY()->setRange(0, m_valueCount);
+ chart->axes(Qt::Horizontal).first()->setRange(0, m_valueMax);
+ chart->axes(Qt::Vertical).first()->setRange(0, m_valueCount);
// Add space to label to add space between labels and axis
- static_cast<QValueAxis *>(chart->axisY())->setLabelFormat("%.1f ");
-
+ QValueAxis *axisY = qobject_cast<QValueAxis*>(chart->axes(Qt::Vertical).first());
+ Q_ASSERT(axisY);
+ axisY->setLabelFormat("%.1f ");
return chart;
}