From 59746c604f2cfcbe370e448577820c60aeef4a23 2012-07-03 10:23:39 From: Marek Rosa Date: 2012-07-03 10:23:39 Subject: [PATCH] Presenter chart updated --- diff --git a/doc/src/examples-presenterchart.qdoc b/doc/src/examples-presenterchart.qdoc index c26b713..9a79fb3 100644 --- a/doc/src/examples-presenterchart.qdoc +++ b/doc/src/examples-presenterchart.qdoc @@ -32,7 +32,7 @@ \snippet ../examples/presenterchart/chartview.cpp 3 - In \c handleTimeout() slot we change currently displayed chart by removing previous series and adding next series from the \c m_series list. We also set proper title. + In \c handleTimeout() slot we change currently displayed chart by removing previous series and adding next series from the \c m_series list. We also set proper title and create the axes for the chart. \snippet ../examples/presenterchart/chartview.cpp 4 */ diff --git a/examples/presenterchart/chartview.cpp b/examples/presenterchart/chartview.cpp index c9d4bba..b350dfd 100644 --- a/examples/presenterchart/chartview.cpp +++ b/examples/presenterchart/chartview.cpp @@ -25,15 +25,17 @@ #include #include -ChartView::ChartView(QChart* chart,QWidget* parent):QChartView(chart,parent), -m_index(-1),m_chart(chart) +ChartView::ChartView(QChart* chart,QWidget* parent): + QChartView(chart,parent), + m_index(-1), + m_chart(chart) { m_chart->setTitle("Charts presenter"); m_chart->setDropShadowEnabled(false); QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); m_timer.setInterval(3000); -//![1] + //![1] QLineSeries* series0 = new QLineSeries(); series0->setName("line"); @@ -45,9 +47,9 @@ m_index(-1),m_chart(chart) QAreaSeries* series3 = new QAreaSeries(series0); series3->setName("area"); -//![1] + //![1] -//![2] + //![2] int numPoints = 10; for (int x = 0; x <= numPoints; ++x) { @@ -56,9 +58,9 @@ m_index(-1),m_chart(chart) series1->append(x,y); series2->append(x,y); } -//![2] + //![2] -//![3] + //![3] m_series<title()+": LineChart"; m_series<title()+": SplineChart"; m_series<title()+": AreaChart"; -//![3] + //![3] m_timer.start(); handleTimeout(); @@ -75,7 +77,7 @@ m_index(-1),m_chart(chart) ChartView::~ChartView() { - if(m_series.size()==0) return; + if(m_series.size() == 0) return; m_chart->removeSeries(m_series.at(m_index)); m_series.removeLast(); //remove QAreaSeries instance since they will be deleted when QLineSeries instance is gone qDeleteAll(m_series); @@ -84,12 +86,13 @@ ChartView::~ChartView() //![4] void ChartView::handleTimeout() { - if(m_series.size()==0) return; - if(m_index>=0) - m_chart->removeSeries(m_series.at(m_index)); + if(m_series.size() == 0) return; + if(m_index >= 0) + m_chart->removeSeries(m_series.at(m_index)); m_index++; - m_index=m_index%m_series.size(); + m_index = m_index % m_series.size(); m_chart->addSeries(m_series.at(m_index)); m_chart->setTitle(m_titles.at(m_index)); + m_chart->createDefaultAxes(); } //![4]