examples-presenterchart.qdoc
36 lines
| 1.7 KiB
| text/plain
|
TextLexer
Michal Klocek
|
r482 | /*! | |
Tero Ahola
|
r500 | \example examples/presenterchart | |
Michal Klocek
|
r482 | \title PresenterChart Example | |
\subtitle | |||
The example shows how to create chart which presents the same set of data as line, scatter and spline charts. | |||
ChartPresenter will switch between these three chart types every few seconds. | |||
Please note this example does not use common data model. A use of common data model is documented here.[TODO] | |||
\image presenterchart1.png | |||
\image presenterchart2.png | |||
\image presenterchart3.png | |||
We create simple ChartView class which derives form QChartView. | |||
sauimone
|
r496 | \snippet ../examples/presenterchart/chartview.h 1 | |
Michal Klocek
|
r482 | ||
Class will implement \c handleTimeout() slot which we are going to use to trigger switching between different chart presentations. | |||
Class members \c m_series and \c m_titles are going to store series and related titles. In example we are going to present data as a line chart | |||
using QLineSeries , as scatter chart using QScatterSeries, and as a spline chart using QSplineSeries. We create needed instances in constructor of ChartView class. | |||
We set custom line and points colors. | |||
sauimone
|
r496 | \snippet ../examples/presenterchart/chartview.cpp 1 | |
Michal Klocek
|
r482 | ||
We add data to all three series. We can use add() member function. If data set is large,it is wiser to use shared data model, as described here.[TODO] | |||
sauimone
|
r496 | \snippet ../examples/presenterchart/chartview.cpp 2 | |
Michal Klocek
|
r482 | ||
In the end we store references all the created series and matching titles. | |||
sauimone
|
r496 | \snippet ../examples/presenterchart/chartview.cpp 3 | |
Michal Klocek
|
r482 | ||
In \c handleTimeout() slot we change currently displayed chart by removing previous series and adding next series from the \c m_series list. We also set proper title. | |||
sauimone
|
r496 | \snippet ../examples/presenterchart/chartview.cpp 4 | |
Michal Klocek
|
r482 | ||
*/ |