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