From 58901e4781597dc2a80cc805fbfd801df44a2e0b 2012-04-03 09:57:45 From: Jani Honkonen Date: 2012-04-03 09:57:45 Subject: [PATCH] Make ekgchart compile --- diff --git a/examples/ekgchart/chartview.cpp b/examples/ekgchart/chart.cpp similarity index 73% rename from examples/ekgchart/chartview.cpp rename to examples/ekgchart/chart.cpp index 6348a54..9a1267c 100644 --- a/examples/ekgchart/chartview.cpp +++ b/examples/ekgchart/chart.cpp @@ -18,20 +18,21 @@ ** ****************************************************************************/ -#include "chartview.h" +#include "chart.h" +#include #include #include -ChartView::ChartView(QWidget* parent):QChartView(parent), -m_step(1), -m_x(0), -m_y(1) +Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags) + :QChart(parent, wFlags), + m_step(1), + m_x(0), + m_y(1) { QTime now = QTime::currentTime(); qsrand((uint)now.msec()); - setChartTitle("Three random line charts"); - QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); + QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimeout())); m_timer.setInterval(1000); m_series0 = new QLineSeries(this); @@ -39,39 +40,36 @@ m_y(1) blue.setWidth(3); m_series0->setPen(blue); - m_series1 = new QSplineSeries(this); QPen green(Qt::red); green.setWidth(3); m_series1->setPen(green); - m_series0->append(m_x,m_y); - m_series1->append(m_x,m_y); + m_series0->append(m_x, m_y); + m_series1->append(m_x, m_y); - setChartTitle("Simple EKG chart"); addSeries(m_series0); addSeries(m_series1); - axisY()->setRange(-5,5); - axisX()->setRange(-9,1); + axisY()->setRange(-5, 5); + axisX()->setRange(-9, 1); axisX()->setTicksCount(11); m_timer.start(); } -ChartView::~ChartView() +Chart::~Chart() { } -void ChartView::handleTimeout() +void Chart::handleTimeout() { - m_x+=m_step; + 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_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); } scrollRight(); } diff --git a/examples/ekgchart/chartview.h b/examples/ekgchart/chart.h similarity index 85% rename from examples/ekgchart/chartview.h rename to examples/ekgchart/chart.h index 9c8a674..54533bc 100644 --- a/examples/ekgchart/chartview.h +++ b/examples/ekgchart/chart.h @@ -18,13 +18,12 @@ ** ****************************************************************************/ -#ifndef CHARTVIEW_H_ -#define CHARTVIEW_H_ +#ifndef CHART_H_ +#define CHART_H_ -#include +#include #include - QTCOMMERCIALCHART_BEGIN_NAMESPACE class QSplineSeries; class QLineSeries; @@ -33,12 +32,12 @@ QTCOMMERCIALCHART_END_NAMESPACE QTCOMMERCIALCHART_USE_NAMESPACE //![1] -class ChartView: public QChartView +class Chart: public QChart { Q_OBJECT public: - ChartView(QWidget* parent = 0); - virtual ~ChartView(); + Chart(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + virtual ~Chart(); public slots: void handleTimeout(); @@ -54,4 +53,4 @@ private: }; //![1] -#endif /* CHARTVIEW_H_ */ +#endif /* CHART_H_ */ diff --git a/examples/ekgchart/ekgchart.pro b/examples/ekgchart/ekgchart.pro index 395db3d..cf38a8e 100644 --- a/examples/ekgchart/ekgchart.pro +++ b/examples/ekgchart/ekgchart.pro @@ -2,5 +2,5 @@ error( "Couldn't find the examples.pri file!" ) } TARGET = ekgchart -HEADERS += chartview.h -SOURCES += main.cpp chartview.cpp \ No newline at end of file +HEADERS += chart.h +SOURCES += main.cpp chart.cpp \ No newline at end of file diff --git a/examples/ekgchart/main.cpp b/examples/ekgchart/main.cpp index 84cbdb4..29a5d0c 100644 --- a/examples/ekgchart/main.cpp +++ b/examples/ekgchart/main.cpp @@ -18,17 +18,22 @@ ** ****************************************************************************/ -#include "chartview.h" +#include "chart.h" +#include #include #include +QTCOMMERCIALCHART_USE_NAMESPACE + int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow window; - ChartView chartView(&window); + Chart *chart = new Chart; + chart->setTitle("Simple EKG chart"); + chart->setAnimationOptions(QChart::AllAnimations); + QChartView chartView(chart); chartView.setRenderHint(QPainter::Antialiasing); - chartView.setAnimationOptions(QChart::AllAnimations); window.setCentralWidget(&chartView); window.resize(400, 300); window.show(); diff --git a/examples/examples.pro b/examples/examples.pro index 2ff04ea..f8f8c01 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -5,7 +5,7 @@ SUBDIRS += \ #chartview \ customchart \ #dynamiclinechart \ - #ekgchart \ + ekgchart \ linechart \ #multichart \ percentbarchart \