O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding a line series to the chart view

We agreed that a reasonable visualization for the near-sinusoidal data produced by the mock sensor and transmitted via the broadcaster is a line series, where subsequent data points are linearly interpolated. You can choose an alternative visualization if you prefer. The LineSeries QML type (https://doc.qt.io/qt-5.9/qml-qtcharts-lineseries.html) should be contained in a ChartView type (https://doc.qt.io/qt-5.9/qml-qtcharts-chartview.html):

// ReadingsChart.qmlimport QtQuick 2.9import QtCharts 2.2ChartView {    id: chartView    LineSeries {
        id: lineSeries    }}

By previewing the QML document with qmlscene, you'll get an empty X/Y chart with a default grid and legend color:

What should we display on the X and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required