##// END OF EJS Templates
Updates presenter example documentation
Michal Klocek -
r574:5a19c3a8f92b
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
@@ -3,26 +3,29
3 3 \title PresenterChart Example
4 4 \subtitle
5 5
6 The example shows how to create chart which presents the same set of data as line, scatter and spline charts.
7 ChartPresenter will switch between these three chart types every few seconds.
6 The example shows how to create chart which presents the same set of data as line, scatter, spline and area charts.
7 ChartPresenter will switch between these four chart types every few seconds.
8 8 Please note this example does not use common data model. A use of common data model is documented here.[TODO]
9 9
10 10 \image presenterchart1.png
11 11 \image presenterchart2.png
12 12 \image presenterchart3.png
13 \image presenterchart4.png
13 14
14 15 We create simple ChartView class which derives form QChartView.
15 16
16 17 \snippet ../examples/presenterchart/chartview.h 1
17 18
18 19 Class will implement \c handleTimeout() slot which we are going to use to trigger switching between different chart presentations.
20 We are also going to provide \c handlePoitClicked() slot which will show clicked point on the chart.
19 21 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
20 using QLineSeries , as scatter chart using QScatterSeries, and as a spline chart using QSplineSeries. We create needed instances in constructor of ChartView class.
22 using QLineSeries , as scatter chart using QScatterSeries, as a spline chart using QSplineSeries and a area chart using QAreaSeries. We create needed instances in constructor of ChartView class.
21 23 We set custom line and points colors.
22 24
23 25 \snippet ../examples/presenterchart/chartview.cpp 1
24 26
25 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]
27 We add data to three series. Please note area chart is going to use QLineSeries as the upper line. We can use add() member function. If data set is large,
28 it is wiser to use shared data model, as described here.[TODO]
26 29
27 30 \snippet ../examples/presenterchart/chartview.cpp 2
28 31
@@ -30,8 +33,16
30 33
31 34 \snippet ../examples/presenterchart/chartview.cpp 3
32 35
33 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.
36 We connect \c clicked() signals from each series with our \c handlePointClciked() slot.
34 37
35 38 \snippet ../examples/presenterchart/chartview.cpp 4
36 39
40 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.
41
42 \snippet ../examples/presenterchart/chartview.cpp 5
43
44 In \c handlePointClciked() slot we set the chart's title to show clicked point x and y coordinates.
45
46 \snippet ../examples/presenterchart/chartview.cpp 6
47
37 48 */ No newline at end of file
@@ -64,9 +64,11 m_index(0)
64 64 addSeries(series0);
65 65 setChartTitle(m_titles.at(0));
66 66
67 //![4]
67 68 foreach (QSeries* series, m_series) {
68 69 QObject::connect(series,SIGNAL(clicked(const QPointF&)),this,SLOT(handlePointClicked(const QPointF&)));
69 70 }
71 //![4]
70 72
71 73 m_timer.start();
72 74 }
@@ -78,7 +80,7 ChartView::~ChartView()
78 80 qDeleteAll(m_series);
79 81 }
80 82
81 //![4]
83 //![5]
82 84 void ChartView::handleTimeout()
83 85 {
84 86 if(m_series.size()==0) return;
@@ -88,9 +90,11 void ChartView::handleTimeout()
88 90 addSeries(m_series.at(m_index));
89 91 setChartTitle(m_titles.at(m_index));
90 92 }
91 //![4]
93 //![5]
92 94
95 //![6]
93 96 void ChartView::handlePointClicked(const QPointF& point)
94 97 {
95 98 setChartTitle(m_titles.at(m_index) + QString(" x: %1 y: %2").arg(point.x()).arg(point.y()));
96 99 }
100 //![6]
@@ -64,6 +64,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
64 64 */
65 65
66 66 /*!
67 \fn void QAreaSeries::clicked(const QPointF& point)
68 \brief Signal is emitted when user clicks the \a point on area chart.
69 */
70
71 /*!
67 72 \fn void QAreaSeries::updated()
68 73 \brief \internal
69 74 */
@@ -37,11 +37,6
37 37 \sa QSeries, QSeriesType
38 38 */
39 39
40 /*!
41 \fn void QScatterSeries::clicked(const QPointF& point)
42 \brief Signal is emitted when user clicks the \a point on scatter chart.
43 */
44
45 40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46 41
47 42 /*!
@@ -20,6 +20,11 QTCOMMERCIALCHART_BEGIN_NAMESPACE
20 20 */
21 21
22 22 /*!
23 \fn void QXYSeries::clicked(const QPointF& point)
24 \brief Signal is emitted when user clicks the \a point on chart.
25 */
26
27 /*!
23 28 \fn void QXYSeries::pointReplaced(int index)
24 29 \brief \internal \a index
25 30 */
General Comments 0
You need to be logged in to leave comments. Login now