diff --git a/example/dynamiclinechart/dynamiclinechart.pro b/example/dynamiclinechart/dynamiclinechart.pro index a700d00..bf78482 100644 --- a/example/dynamiclinechart/dynamiclinechart.pro +++ b/example/dynamiclinechart/dynamiclinechart.pro @@ -10,7 +10,7 @@ TARGET = dynamicLineChart TEMPLATE = app QT += core gui SOURCES += main.cpp -HEADERS += updater.h +HEADERS += wavegenerator.h diff --git a/example/dynamiclinechart/main.cpp b/example/dynamiclinechart/main.cpp index 682b932..541a4bf 100644 --- a/example/dynamiclinechart/main.cpp +++ b/example/dynamiclinechart/main.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "updater.h" +#include "wavegenerator.h" int main(int argc, char *argv[]) { @@ -21,15 +21,12 @@ int main(int argc, char *argv[]) red.setWidth(3); series1->setPen(red); - for (int x = 0; x <= numPoints; ++x) { - series0->add(x, fabs(sin(PI/50*x)*100)); - series1->add(x, fabs(cos(PI/50*x)*100)); - } + WaveGenerator generator(series0,series1); QChartView* chartView = new QChartView(&window); chartView->setRenderHint(QPainter::Antialiasing); - chartView->setTitle("Basic line chart example"); + chartView->setTitle("This is wave generator buahha."); chartView->addSeries(series0); chartView->addSeries(series1); @@ -37,7 +34,5 @@ int main(int argc, char *argv[]) window.resize(400, 300); window.show(); - Updater updater(series0,series1); - return a.exec(); } diff --git a/example/dynamiclinechart/updater.h b/example/dynamiclinechart/updater.h deleted file mode 100644 index 4028304..0000000 --- a/example/dynamiclinechart/updater.h +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -#define PI 3.14159265358979 -static const int numPoints =100; - -class Updater: public QObject -{ - Q_OBJECT - -public: - Updater(QXYChartSeries* series1, QXYChartSeries* series2) : - m_series1(series1), - m_series2(series2) - { - QTimer::singleShot(5000, this, SLOT(update())); - }; - -public slots: - void update() - { - for (int x = 0; x <= numPoints; ++x) { - m_series1->set(x, x, fabs(cos(PI / 50 * x)*100)); - m_series2->set(x, x, fabs(sin(PI / 50 * x)*100)); - } - }; - -private: - QXYChartSeries* m_series1; - QXYChartSeries* m_series2; -};