example-splinechart.qdoc
42 lines
| 1.6 KiB
| text/plain
|
TextLexer
Marek Rosa
|
r435 | /*! | ||
Tero Ahola
|
r500 | \example examples/splinechart | ||
Marek Rosa
|
r435 | \title SplineChart Example | ||
\subtitle | ||||
The example shows how to create simple spline chart. | ||||
\image splinechart_example | ||||
To create spline chart we need to put our data into QSplineSeries. QSplineSeries automatically calculates spline segment control points that are needed to properly draw the spline. | ||||
sauimone
|
r496 | \snippet ../examples/splinechart/splinewidget.cpp 1 | ||
Marek Rosa
|
r435 | |||
Customize the look of the spline, by setting its pen's color and pen's width | ||||
sauimone
|
r496 | \snippet ../examples/splinechart/splinewidget.cpp 2 | ||
Marek Rosa
|
r435 | |||
Now lets add some data points to the series. | ||||
sauimone
|
r496 | \snippet ../examples/splinechart/splinewidget.cpp add points to series | ||
Marek Rosa
|
r435 | |||
The data series has been populated. To display it on a chart we create QChartView object and add the data series to it. We also set the ranges on both axises, so that our chart is fully visible and there is some excess of space for adding more data points. | ||||
sauimone
|
r496 | \snippet ../examples/splinechart/splinewidget.cpp 3 | ||
Marek Rosa
|
r435 | |||
Then we add two buttons for adding and removing data points. Buttons clicked() signals are connected to handler functions. | ||||
sauimone
|
r496 | \snippet ../examples/splinechart/splinewidget.cpp 4 | ||
Marek Rosa
|
r435 | |||
In the end we add the chart and the buttons to the widget's layout. | ||||
sauimone
|
r496 | \snippet ../examples/splinechart/splinewidget.cpp 5 | ||
Marek Rosa
|
r435 | |||
Here is the handler function for add new data point button: | ||||
sauimone
|
r496 | \snippet ../examples/splinechart/splinewidget.cpp add point | ||
Marek Rosa
|
r435 | |||
And here is one for remove the last data point in the series: | ||||
sauimone
|
r496 | \snippet ../examples/splinechart/splinewidget.cpp remove point | ||
Marek Rosa
|
r435 | |||
*/ | ||||