##// END OF EJS Templates
Fix compilation of presenter chart
Michal Klocek -
r866:0933fdb2e8e1
parent child
Show More
@@ -8,7 +8,7 SUBDIRS += \
8 percentbarchart \
8 percentbarchart \
9 piechart \
9 piechart \
10 piechartdrilldown \
10 piechartdrilldown \
11 #presenterchart \
11 presenterchart \
12 scatterchart \
12 scatterchart \
13 scatterinteractions \
13 scatterinteractions \
14 splinechart \
14 splinechart \
@@ -25,10 +25,10
25 #include <QAreaSeries>
25 #include <QAreaSeries>
26 #include <QTime>
26 #include <QTime>
27
27
28 ChartView::ChartView(QWidget* parent):QChartView(parent),
28 ChartView::ChartView(QChart* chart,QWidget* parent):QChartView(chart,parent),
29 m_index(0)
29 m_index(0),m_chart(chart)
30 {
30 {
31 setChartTitle("Charts presenter");
31 m_chart->setTitle("Charts presenter");
32 QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
32 QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
33 m_timer.setInterval(3000);
33 m_timer.setInterval(3000);
34
34
@@ -69,17 +69,17 m_index(0)
69
69
70 //![3]
70 //![3]
71 m_series<<series0;
71 m_series<<series0;
72 m_titles<<chartTitle()+": LineChart";
72 m_titles<< m_chart->title()+": LineChart";
73 m_series<<series1;
73 m_series<<series1;
74 m_titles<<chartTitle()+": ScatterChart";
74 m_titles<< m_chart->title()+": ScatterChart";
75 m_series<<series2;
75 m_series<<series2;
76 m_titles<<chartTitle()+": SplineChart";
76 m_titles<< m_chart->title()+": SplineChart";
77 m_series<<series3;
77 m_series<<series3;
78 m_titles<<chartTitle()+": AreaChart";
78 m_titles<< m_chart->title()+": AreaChart";
79 //![3]
79 //![3]
80
80
81 addSeries(series0);
81 m_chart->addSeries(series0);
82 setChartTitle(m_titles.at(0));
82 m_chart->setTitle(m_titles.at(0));
83
83
84 //![4]
84 //![4]
85 foreach (QSeries* series, m_series) {
85 foreach (QSeries* series, m_series) {
@@ -93,7 +93,7 m_index(0)
93 ChartView::~ChartView()
93 ChartView::~ChartView()
94 {
94 {
95 if(m_series.size()==0) return;
95 if(m_series.size()==0) return;
96 removeSeries(m_series.at(m_index));
96 m_chart->removeSeries(m_series.at(m_index));
97 qDeleteAll(m_series);
97 qDeleteAll(m_series);
98 }
98 }
99
99
@@ -101,17 +101,17 ChartView::~ChartView()
101 void ChartView::handleTimeout()
101 void ChartView::handleTimeout()
102 {
102 {
103 if(m_series.size()==0) return;
103 if(m_series.size()==0) return;
104 removeSeries(m_series.at(m_index));
104 m_chart->removeSeries(m_series.at(m_index));
105 m_index++;
105 m_index++;
106 m_index=m_index%m_series.size();
106 m_index=m_index%m_series.size();
107 addSeries(m_series.at(m_index));
107 m_chart->addSeries(m_series.at(m_index));
108 setChartTitle(m_titles.at(m_index));
108 m_chart->setTitle(m_titles.at(m_index));
109 }
109 }
110 //![5]
110 //![5]
111
111
112 //![6]
112 //![6]
113 void ChartView::handlePointClicked(const QPointF& point)
113 void ChartView::handlePointClicked(const QPointF& point)
114 {
114 {
115 setChartTitle(m_titles.at(m_index) + QString(" x: %1 y: %2").arg(point.x()).arg(point.y()));
115 m_chart->setTitle(m_titles.at(m_index) + QString(" x: %1 y: %2").arg(point.x()).arg(point.y()));
116 }
116 }
117 //![6]
117 //![6]
@@ -31,7 +31,7 class ChartView: public QChartView
31 {
31 {
32 Q_OBJECT
32 Q_OBJECT
33 public:
33 public:
34 ChartView(QWidget* parent = 0);
34 ChartView(QChart* chart,QWidget* parent = 0);
35 virtual ~ChartView();
35 virtual ~ChartView();
36
36
37 public slots:
37 public slots:
@@ -43,6 +43,7 private:
43 QList<QSeries*> m_series;
43 QList<QSeries*> m_series;
44 QStringList m_titles;
44 QStringList m_titles;
45 int m_index;
45 int m_index;
46 QChart *m_chart;
46 };
47 };
47 //![1]
48 //![1]
48
49
@@ -26,9 +26,10 int main(int argc, char *argv[])
26 {
26 {
27 QApplication a(argc, argv);
27 QApplication a(argc, argv);
28 QMainWindow window;
28 QMainWindow window;
29 ChartView chartView(&window);
29 QChart* chart = new QChart();
30 ChartView chartView(chart,&window);
30 chartView.setRenderHint(QPainter::Antialiasing);
31 chartView.setRenderHint(QPainter::Antialiasing);
31 chartView.setAnimationOptions(QChart::AllAnimations);
32 chart->setAnimationOptions(QChart::AllAnimations);
32 window.setCentralWidget(&chartView);
33 window.setCentralWidget(&chartView);
33 window.resize(400, 300);
34 window.resize(400, 300);
34 window.show();
35 window.show();
General Comments 0
You need to be logged in to leave comments. Login now