##// END OF EJS Templates
Make ekgchart compile
Jani Honkonen -
r840:58901e478159
parent child
Show More
@@ -1,77 +1,75
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "chartview.h"
21 #include "chart.h"
22 #include <QChartAxis>
22 #include <QSplineSeries>
23 #include <QSplineSeries>
23 #include <QTime>
24 #include <QTime>
24
25
25 ChartView::ChartView(QWidget* parent):QChartView(parent),
26 Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
27 :QChart(parent, wFlags),
26 m_step(1),
28 m_step(1),
27 m_x(0),
29 m_x(0),
28 m_y(1)
30 m_y(1)
29 {
31 {
30 QTime now = QTime::currentTime();
32 QTime now = QTime::currentTime();
31 qsrand((uint)now.msec());
33 qsrand((uint)now.msec());
32 setChartTitle("Three random line charts");
33
34
34 QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
35 QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
35 m_timer.setInterval(1000);
36 m_timer.setInterval(1000);
36
37
37 m_series0 = new QLineSeries(this);
38 m_series0 = new QLineSeries(this);
38 QPen blue(Qt::blue);
39 QPen blue(Qt::blue);
39 blue.setWidth(3);
40 blue.setWidth(3);
40 m_series0->setPen(blue);
41 m_series0->setPen(blue);
41
42
42
43 m_series1 = new QSplineSeries(this);
43 m_series1 = new QSplineSeries(this);
44 QPen green(Qt::red);
44 QPen green(Qt::red);
45 green.setWidth(3);
45 green.setWidth(3);
46 m_series1->setPen(green);
46 m_series1->setPen(green);
47
47
48 m_series0->append(m_x,m_y);
48 m_series0->append(m_x, m_y);
49 m_series1->append(m_x,m_y);
49 m_series1->append(m_x, m_y);
50
50
51 setChartTitle("Simple EKG chart");
52 addSeries(m_series0);
51 addSeries(m_series0);
53 addSeries(m_series1);
52 addSeries(m_series1);
54 axisY()->setRange(-5,5);
53 axisY()->setRange(-5, 5);
55 axisX()->setRange(-9,1);
54 axisX()->setRange(-9, 1);
56 axisX()->setTicksCount(11);
55 axisX()->setTicksCount(11);
57 m_timer.start();
56 m_timer.start();
58 }
57 }
59
58
60 ChartView::~ChartView()
59 Chart::~Chart()
61 {
60 {
62
61
63 }
62 }
64
63
65 void ChartView::handleTimeout()
64 void Chart::handleTimeout()
66 {
65 {
67 m_x+=m_step;
66 m_x += m_step;
68 m_y = qrand() % 5 - 2.5;
67 m_y = qrand() % 5 - 2.5;
69 m_series0->append(m_x,m_y);
68 m_series0->append(m_x, m_y);
70 m_series1->append(m_x,m_y);
69 m_series1->append(m_x, m_y);
71 if(m_x>=10)
70 if (m_x >= 10) {
72 {
73 m_series0->remove(m_x-10);
71 m_series0->remove(m_x - 10);
74 m_series1->remove(m_x-10);
72 m_series1->remove(m_x - 10);
75 }
73 }
76 scrollRight();
74 scrollRight();
77 }
75 }
@@ -1,57 +1,56
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTVIEW_H_
21 #ifndef CHART_H_
22 #define CHARTVIEW_H_
22 #define CHART_H_
23
23
24 #include <QChartView>
24 #include <QChart>
25 #include <QTimer>
25 #include <QTimer>
26
26
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 class QSplineSeries;
28 class QSplineSeries;
30 class QLineSeries;
29 class QLineSeries;
31 QTCOMMERCIALCHART_END_NAMESPACE
30 QTCOMMERCIALCHART_END_NAMESPACE
32
31
33 QTCOMMERCIALCHART_USE_NAMESPACE
32 QTCOMMERCIALCHART_USE_NAMESPACE
34
33
35 //![1]
34 //![1]
36 class ChartView: public QChartView
35 class Chart: public QChart
37 {
36 {
38 Q_OBJECT
37 Q_OBJECT
39 public:
38 public:
40 ChartView(QWidget* parent = 0);
39 Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
41 virtual ~ChartView();
40 virtual ~Chart();
42
41
43 public slots:
42 public slots:
44 void handleTimeout();
43 void handleTimeout();
45
44
46 private:
45 private:
47 QTimer m_timer;
46 QTimer m_timer;
48 QLineSeries* m_series0;
47 QLineSeries* m_series0;
49 QSplineSeries* m_series1;
48 QSplineSeries* m_series1;
50 QStringList m_titles;
49 QStringList m_titles;
51 qreal m_step;
50 qreal m_step;
52 qreal m_x;
51 qreal m_x;
53 qreal m_y;
52 qreal m_y;
54 };
53 };
55 //![1]
54 //![1]
56
55
57 #endif /* CHARTVIEW_H_ */
56 #endif /* CHART_H_ */
@@ -1,6 +1,6
1 !include( ../examples.pri ) {
1 !include( ../examples.pri ) {
2 error( "Couldn't find the examples.pri file!" )
2 error( "Couldn't find the examples.pri file!" )
3 }
3 }
4 TARGET = ekgchart
4 TARGET = ekgchart
5 HEADERS += chartview.h
5 HEADERS += chart.h
6 SOURCES += main.cpp chartview.cpp No newline at end of file
6 SOURCES += main.cpp chart.cpp No newline at end of file
@@ -1,36 +1,41
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "chartview.h"
21 #include "chart.h"
22 #include <QChartView>
22 #include <QApplication>
23 #include <QApplication>
23 #include <QMainWindow>
24 #include <QMainWindow>
24
25
26 QTCOMMERCIALCHART_USE_NAMESPACE
27
25 int main(int argc, char *argv[])
28 int main(int argc, char *argv[])
26 {
29 {
27 QApplication a(argc, argv);
30 QApplication a(argc, argv);
28 QMainWindow window;
31 QMainWindow window;
29 ChartView chartView(&window);
32 Chart *chart = new Chart;
33 chart->setTitle("Simple EKG chart");
34 chart->setAnimationOptions(QChart::AllAnimations);
35 QChartView chartView(chart);
30 chartView.setRenderHint(QPainter::Antialiasing);
36 chartView.setRenderHint(QPainter::Antialiasing);
31 chartView.setAnimationOptions(QChart::AllAnimations);
32 window.setCentralWidget(&chartView);
37 window.setCentralWidget(&chartView);
33 window.resize(400, 300);
38 window.resize(400, 300);
34 window.show();
39 window.show();
35 return a.exec();
40 return a.exec();
36 }
41 }
@@ -1,29 +1,29
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 SUBDIRS += \
2 SUBDIRS += \
3 areachart \
3 areachart \
4 barchart \
4 barchart \
5 #chartview \
5 #chartview \
6 customchart \
6 customchart \
7 #dynamiclinechart \
7 #dynamiclinechart \
8 #ekgchart \
8 ekgchart \
9 linechart \
9 linechart \
10 #multichart \
10 #multichart \
11 percentbarchart \
11 percentbarchart \
12 piechart \
12 piechart \
13 piechartdrilldown \
13 piechartdrilldown \
14 #presenterchart \
14 #presenterchart \
15 scatterchart \
15 scatterchart \
16 scatterinteractions \
16 scatterinteractions \
17 splinechart \
17 splinechart \
18 stackedbarchart \
18 stackedbarchart \
19 stackedbarchartdrilldown \
19 stackedbarchartdrilldown \
20 tablemodelchart \
20 tablemodelchart \
21 zoomlinechart
21 zoomlinechart
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29
General Comments 0
You need to be logged in to leave comments. Login now