examples-linechart.qdoc
30 lines
| 980 B
| text/plain
|
TextLexer
Michal Klocek
|
r330 | /*! | ||
Tero Ahola
|
r500 | \example examples/linechart | ||
Michal Klocek
|
r330 | \title LineChart Example | ||
\subtitle | ||||
The example shows how to create simple line chart. | ||||
Tero Ahola
|
r979 | \image examples_linechart.png | ||
Michal Klocek
|
r370 | |||
Marek Rosa
|
r902 | To create line chart, QLineSeries instance is needed. Let's create one. | ||
Michal Klocek
|
r370 | |||
sauimone
|
r496 | \snippet ../examples/linechart/main.cpp 1 | ||
Michal Klocek
|
r370 | |||
Marek Rosa
|
r2012 | Then we add data to series. We can use append() member function or use stream operator. | ||
Michal Klocek
|
r370 | |||
sauimone
|
r496 | \snippet ../examples/linechart/main.cpp 2 | ||
Michal Klocek
|
r370 | |||
Mika Salmela
|
r2456 | To present the data on the chart we need QChart instance. We add the series to it, create the default axes and set the title of the chart. | ||
Michal Klocek
|
r370 | |||
sauimone
|
r496 | \snippet ../examples/linechart/main.cpp 3 | ||
Marek Rosa
|
r902 | |||
Then we create a QChartView object with QChart as a parameter. This way we don't need to create QGraphicsView scene ourselves. We also set the Antialiasing on to have the rendered lines look nicer. | ||||
Michal Klocek
|
r370 | |||
sauimone
|
r496 | \snippet ../examples/linechart/main.cpp 4 | ||
Marek Rosa
|
r902 | |||
Chart is ready to be shown. | ||||
\snippet ../examples/linechart/main.cpp 5 | ||||
Michal Klocek
|
r370 | |||
Marek Rosa
|
r902 | */ | ||