summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/dynamicspline/chart.cpp (renamed from examples/ekgchart/chart.cpp)28
-rw-r--r--examples/dynamicspline/chart.h (renamed from examples/ekgchart/chart.h)4
-rw-r--r--examples/dynamicspline/dynamicspline.pro (renamed from examples/ekgchart/ekgchart.pro)4
-rw-r--r--examples/dynamicspline/main.cpp (renamed from examples/ekgchart/main.cpp)2
-rw-r--r--examples/examples.pro2
5 files changed, 14 insertions, 26 deletions
diff --git a/examples/ekgchart/chart.cpp b/examples/dynamicspline/chart.cpp
index 9a1267c0..5d8cc28f 100644
--- a/examples/ekgchart/chart.cpp
+++ b/examples/dynamicspline/chart.cpp
@@ -29,30 +29,23 @@ Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
m_x(0),
m_y(1)
{
- QTime now = QTime::currentTime();
- qsrand((uint)now.msec());
+ qsrand((uint) QTime::currentTime().msec());
QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
m_timer.setInterval(1000);
- m_series0 = new QLineSeries(this);
- QPen blue(Qt::blue);
- blue.setWidth(3);
- m_series0->setPen(blue);
-
- m_series1 = new QSplineSeries(this);
+ m_series = new QSplineSeries(this);
QPen green(Qt::red);
green.setWidth(3);
- m_series1->setPen(green);
+ m_series->setPen(green);
+ m_series->append(m_x, m_y);
- m_series0->append(m_x, m_y);
- m_series1->append(m_x, m_y);
+ addSeries(m_series);
- addSeries(m_series0);
- addSeries(m_series1);
axisY()->setRange(-5, 5);
axisX()->setRange(-9, 1);
axisX()->setTicksCount(11);
+
m_timer.start();
}
@@ -65,11 +58,8 @@ void Chart::handleTimeout()
{
m_x += m_step;
m_y = qrand() % 5 - 2.5;
- m_series0->append(m_x, m_y);
- m_series1->append(m_x, m_y);
- if (m_x >= 10) {
- m_series0->remove(m_x - 10);
- m_series1->remove(m_x - 10);
- }
+ m_series->append(m_x, m_y);
+ if (m_x >= 10)
+ m_series->remove(m_x - 10);
scrollRight();
}
diff --git a/examples/ekgchart/chart.h b/examples/dynamicspline/chart.h
index 54533bc0..7611dfab 100644
--- a/examples/ekgchart/chart.h
+++ b/examples/dynamicspline/chart.h
@@ -26,7 +26,6 @@
QTCOMMERCIALCHART_BEGIN_NAMESPACE
class QSplineSeries;
-class QLineSeries;
QTCOMMERCIALCHART_END_NAMESPACE
QTCOMMERCIALCHART_USE_NAMESPACE
@@ -44,8 +43,7 @@ public slots:
private:
QTimer m_timer;
- QLineSeries* m_series0;
- QSplineSeries* m_series1;
+ QSplineSeries* m_series;
QStringList m_titles;
qreal m_step;
qreal m_x;
diff --git a/examples/ekgchart/ekgchart.pro b/examples/dynamicspline/dynamicspline.pro
index cf38a8e7..68ca88d6 100644
--- a/examples/ekgchart/ekgchart.pro
+++ b/examples/dynamicspline/dynamicspline.pro
@@ -1,6 +1,6 @@
!include( ../examples.pri ) {
error( "Couldn't find the examples.pri file!" )
}
-TARGET = ekgchart
+TARGET = dynamicspline
HEADERS += chart.h
-SOURCES += main.cpp chart.cpp \ No newline at end of file
+SOURCES += main.cpp chart.cpp
diff --git a/examples/ekgchart/main.cpp b/examples/dynamicspline/main.cpp
index 29a5d0c9..bea00b3a 100644
--- a/examples/ekgchart/main.cpp
+++ b/examples/dynamicspline/main.cpp
@@ -30,7 +30,7 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
QMainWindow window;
Chart *chart = new Chart;
- chart->setTitle("Simple EKG chart");
+ chart->setTitle("Dynamic spline chart");
chart->setAnimationOptions(QChart::AllAnimations);
QChartView chartView(chart);
chartView.setRenderHint(QPainter::Antialiasing);
diff --git a/examples/examples.pro b/examples/examples.pro
index ed20c16f..6a2d59c5 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -3,7 +3,7 @@ SUBDIRS += \
areachart \
barchart \
customchart \
- ekgchart \
+ dynamicspline \
linechart \
percentbarchart \
piechart \