##// END OF EJS Templates
Adds ekg example draft
Michal Klocek -
r599:86354d1a97be
parent child
Show More
@@ -0,0 +1,53
1 #include "chartview.h"
2 #include <QSplineSeries>
3 #include <QTime>
4
5 ChartView::ChartView(QWidget* parent):QChartView(parent),
6 m_step(1),
7 m_x(0),
8 m_y(1)
9 {
10 QTime now = QTime::currentTime();
11 qsrand((uint)now.msec());
12 setChartTitle("Three random line charts");
13
14 QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
15 m_timer.setInterval(1000);
16
17 m_series0 = new QLineSeries(this);
18 QPen blue(Qt::blue);
19 blue.setWidth(3);
20 m_series0->setPen(blue);
21
22
23 m_series1 = new QSplineSeries(this);
24 QPen green(Qt::green);
25 green.setWidth(3);
26 m_series1->setPen(green);
27
28
29 m_series0->add(m_x,m_y);
30 m_series1->add(m_x,m_y);
31
32 setChartTitle("Simple EKG exmaple");
33 addSeries(m_series0);
34 addSeries(m_series1);
35 axisY()->setRange(-5,5);
36 axisX()->setRange(-9,1);
37 axisX()->setTicksCount(11);
38 m_timer.start();
39 }
40
41 ChartView::~ChartView()
42 {
43
44 }
45
46 void ChartView::handleTimeout()
47 {
48 m_x+=m_step;
49 m_y = qrand() % 5 - 2.5;
50 m_series0->add(m_x,m_y);
51 m_series1->add(m_x,m_y);
52 scrollRight();
53 }
@@ -0,0 +1,37
1 #ifndef CHARTVIEW_H_
2 #define CHARTVIEW_H_
3
4 #include <QChartView>
5 #include <QTimer>
6
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 class QSplineSeries;
10 class QLineSeries;
11 QTCOMMERCIALCHART_END_NAMESPACE
12
13 QTCOMMERCIALCHART_USE_NAMESPACE
14
15 //![1]
16 class ChartView: public QChartView
17 {
18 Q_OBJECT
19 public:
20 ChartView(QWidget* parent=0);
21 virtual ~ChartView();
22
23 public slots:
24 void handleTimeout();
25
26 private:
27 QTimer m_timer;
28 QLineSeries* m_series0;
29 QSplineSeries* m_series1;
30 QStringList m_titles;
31 qreal m_step;
32 qreal m_x;
33 qreal m_y;
34 };
35 //![1]
36
37 #endif /* CHARTVIEW_H_ */
@@ -0,0 +1,6
1 !include( ../examples.pri ) {
2 error( "Couldn't find the examples.pri file!" )
3 }
4 TARGET = ekgchart
5 HEADERS += chartview.h
6 SOURCES += main.cpp chartview.cpp No newline at end of file
@@ -0,0 +1,16
1 #include "chartview.h"
2 #include <QApplication>
3 #include <QMainWindow>
4
5 int main(int argc, char *argv[])
6 {
7 QApplication a(argc, argv);
8 QMainWindow window;
9 ChartView chartView(&window);
10 chartView.setRenderHint(QPainter::Antialiasing);
11 chartView.setAnimationOptions(QChart::AllAnimations);
12 window.setCentralWidget(&chartView);
13 window.resize(400, 300);
14 window.show();
15 return a.exec();
16 }
@@ -1,22 +1,23
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 SUBDIRS += linechart \
2 SUBDIRS += linechart \
3 zoomlinechart \
3 zoomlinechart \
4 colorlinechart \
4 colorlinechart \
5 barchart \
5 barchart \
6 stackedbarchart \
6 stackedbarchart \
7 percentbarchart \
7 percentbarchart \
8 scatterchart \
8 scatterchart \
9 piechart \
9 piechart \
10 piechartdrilldown \
10 piechartdrilldown \
11 dynamiclinechart \
11 dynamiclinechart \
12 axischart \
12 axischart \
13 multichart \
13 multichart \
14 gdpbarchart \
14 gdpbarchart \
15 presenterchart \
15 presenterchart \
16 chartview \
16 chartview \
17 scatterinteractions \
17 scatterinteractions \
18 splinechart \
18 splinechart \
19 areachart \
19 areachart \
20 stackedbarchartdrilldown \
20 stackedbarchartdrilldown \
21 customcolors \
21 customcolors \
22 tablemodelchart
22 tablemodelchart \
23 ekgchart
General Comments 0
You need to be logged in to leave comments. Login now