diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2016-09-21 14:45:41 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2016-09-23 09:55:41 +0000 |
commit | 3cb2c5e7572a75a4fae8883c9c0f3141cdf207b9 (patch) | |
tree | 1fa529e85c919755d9d4048b8240a6876d34199a /examples/charts/scatterchart | |
parent | 06c412094b60517af015637322798da6224e34c2 (diff) |
Add a possibility to change legend marker shape
It is now possible to choose between rectangular, circular, and
"from series" shapes for legend markers. The "from series" shape uses
scatter dot items as legend markers in case of scatter series and
a line segment for line and spline series.
Task-number: QTBUG-50682
Change-Id: I58977ead88e1274e1f163516d32c4d290f4410f9
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'examples/charts/scatterchart')
-rw-r--r-- | examples/charts/scatterchart/chartview.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/charts/scatterchart/chartview.cpp b/examples/charts/scatterchart/chartview.cpp index 3a6c9240..c2f099c1 100644 --- a/examples/charts/scatterchart/chartview.cpp +++ b/examples/charts/scatterchart/chartview.cpp @@ -69,10 +69,10 @@ ChartView::ChartView(QWidget *parent) : //![3] QPainterPath starPath; - starPath.moveTo(30, 15); + starPath.moveTo(28, 15); for (int i = 1; i < 5; ++i) { - starPath.lineTo(15 + 15 * qCos(0.8 * i * Pi), - 15 + 15 * qSin(0.8 * i * Pi)); + starPath.lineTo(14 + 14 * qCos(0.8 * i * Pi), + 15 + 14 * qSin(0.8 * i * Pi)); } starPath.closeSubpath(); @@ -86,6 +86,7 @@ ChartView::ChartView(QWidget *parent) : painter.drawPath(starPath); series2->setBrush(star); + series2->setPen(QColor(Qt::transparent)); //![3] //![4] @@ -100,8 +101,6 @@ ChartView::ChartView(QWidget *parent) : //![4] //![5] - QList<QLegendMarker *> markers = chart()->legend()->markers(series2); - for (int i = 0; i < markers.count(); i++) - markers.at(i)->setBrush(painter.pen().color()); + chart()->legend()->setMarkerShape(QLegend::MarkerShapeFromSeries); //![5] } |