##// END OF EJS Templates
Rename ekgchart -> dynamicspline
Jani Honkonen -
r977:0f732f6459ec
parent child
Show More
@@ -29,30 +29,23 Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
29 m_x(0),
29 m_x(0),
30 m_y(1)
30 m_y(1)
31 {
31 {
32 QTime now = QTime::currentTime();
32 qsrand((uint) QTime::currentTime().msec());
33 qsrand((uint)now.msec());
34
33
35 QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
34 QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
36 m_timer.setInterval(1000);
35 m_timer.setInterval(1000);
37
36
38 m_series0 = new QLineSeries(this);
37 m_series = new QSplineSeries(this);
39 QPen blue(Qt::blue);
40 blue.setWidth(3);
41 m_series0->setPen(blue);
42
43 m_series1 = new QSplineSeries(this);
44 QPen green(Qt::red);
38 QPen green(Qt::red);
45 green.setWidth(3);
39 green.setWidth(3);
46 m_series1->setPen(green);
40 m_series->setPen(green);
41 m_series->append(m_x, m_y);
47
42
48 m_series0->append(m_x, m_y);
43 addSeries(m_series);
49 m_series1->append(m_x, m_y);
50
44
51 addSeries(m_series0);
52 addSeries(m_series1);
53 axisY()->setRange(-5, 5);
45 axisY()->setRange(-5, 5);
54 axisX()->setRange(-9, 1);
46 axisX()->setRange(-9, 1);
55 axisX()->setTicksCount(11);
47 axisX()->setTicksCount(11);
48
56 m_timer.start();
49 m_timer.start();
57 }
50 }
58
51
@@ -65,11 +58,8 void Chart::handleTimeout()
65 {
58 {
66 m_x += m_step;
59 m_x += m_step;
67 m_y = qrand() % 5 - 2.5;
60 m_y = qrand() % 5 - 2.5;
68 m_series0->append(m_x, m_y);
61 m_series->append(m_x, m_y);
69 m_series1->append(m_x, m_y);
62 if (m_x >= 10)
70 if (m_x >= 10) {
63 m_series->remove(m_x - 10);
71 m_series0->remove(m_x - 10);
72 m_series1->remove(m_x - 10);
73 }
74 scrollRight();
64 scrollRight();
75 }
65 }
@@ -26,7 +26,6
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 class QSplineSeries;
28 class QSplineSeries;
29 class QLineSeries;
30 QTCOMMERCIALCHART_END_NAMESPACE
29 QTCOMMERCIALCHART_END_NAMESPACE
31
30
32 QTCOMMERCIALCHART_USE_NAMESPACE
31 QTCOMMERCIALCHART_USE_NAMESPACE
@@ -44,8 +43,7 public slots:
44
43
45 private:
44 private:
46 QTimer m_timer;
45 QTimer m_timer;
47 QLineSeries* m_series0;
46 QSplineSeries* m_series;
48 QSplineSeries* m_series1;
49 QStringList m_titles;
47 QStringList m_titles;
50 qreal m_step;
48 qreal m_step;
51 qreal m_x;
49 qreal m_x;
@@ -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 = dynamicspline
5 HEADERS += chart.h
5 HEADERS += chart.h
6 SOURCES += main.cpp chart.cpp No newline at end of file
6 SOURCES += main.cpp chart.cpp
@@ -30,7 +30,7 int main(int argc, char *argv[])
30 QApplication a(argc, argv);
30 QApplication a(argc, argv);
31 QMainWindow window;
31 QMainWindow window;
32 Chart *chart = new Chart;
32 Chart *chart = new Chart;
33 chart->setTitle("Simple EKG chart");
33 chart->setTitle("Dynamic spline chart");
34 chart->setAnimationOptions(QChart::AllAnimations);
34 chart->setAnimationOptions(QChart::AllAnimations);
35 QChartView chartView(chart);
35 QChartView chartView(chart);
36 chartView.setRenderHint(QPainter::Antialiasing);
36 chartView.setRenderHint(QPainter::Antialiasing);
@@ -3,7 +3,7 SUBDIRS += \
3 areachart \
3 areachart \
4 barchart \
4 barchart \
5 customchart \
5 customchart \
6 ekgchart \
6 dynamicspline \
7 linechart \
7 linechart \
8 percentbarchart \
8 percentbarchart \
9 piechart \
9 piechart \
General Comments 0
You need to be logged in to leave comments. Login now