##// END OF EJS Templates
Improved modelData example visual appearance
Improved modelData example visual appearance

File last commit:

r1015:5ddcd5974481
r1030:5594c69cffa0
Show More
chartview.cpp
105 lines | 2.9 KiB | text/x-c | CppLexer
Jani Honkonen
Add/modify license headers
r830 /****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
Michal Klocek
Adds preseterchart example
r246 #include "chartview.h"
Michal Klocek
Change headers to qt ones in some examples
r632 #include <QLineSeries>
#include <QScatterSeries>
#include <QSplineSeries>
#include <QAreaSeries>
Michal Klocek
Adds preseterchart example
r246 #include <QTime>
Michal Klocek
Fix compilation of presenter chart
r866 ChartView::ChartView(QChart* chart,QWidget* parent):QChartView(chart,parent),
Michal Klocek
Updates preseter example
r868 m_index(-1),m_chart(chart)
Michal Klocek
Adds preseterchart example
r246 {
Michal Klocek
Fix compilation of presenter chart
r866 m_chart->setTitle("Charts presenter");
Tero Ahola
Fixed presenter and scatter examples and their documentation.
r1015 m_chart->setBackgroundDropShadowEnabled(false);
Michal Klocek
Adds preseterchart example
r246 QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
m_timer.setInterval(3000);
Michal Klocek
Adds chartPresenter example to docs
r482 //![1]
Michal Klocek
Fixes chart presenter crash on exit
r981 QLineSeries* series0 = new QLineSeries();
Michal Klocek
Adds preseterchart example
r246 QPen blue(Qt::blue);
blue.setWidth(3);
series0->setPen(blue);
Michal Klocek
Adds chartPresenter example to docs
r482
Michal Klocek
Fixes chart presenter crash on exit
r981 QScatterSeries* series1 = new QScatterSeries();
Michal Klocek
Adds preseterchart example
r246 QPen red(Qt::red);
red.setWidth(3);
series1->setPen(red);
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 series1->setBrush(Qt::white);
Michal Klocek
Adds chartPresenter example to docs
r482
Michal Klocek
Fixes chart presenter crash on exit
r981 QSplineSeries* series2 = new QSplineSeries();
Michal Klocek
Adds preseterchart example
r246 QPen green(Qt::green);
green.setWidth(3);
series2->setPen(green);
Michal Klocek
Adds area chart animations...
r560
QAreaSeries* series3 = new QAreaSeries(series0);
QPen yellow(Qt::black);
yellow.setWidth(3);
series3->setPen(yellow);
series3->setBrush(Qt::yellow);
Michal Klocek
Adds chartPresenter example to docs
r482 //![1]
Michal Klocek
Adds preseterchart example
r246
Michal Klocek
Adds chartPresenter example to docs
r482 //![2]
Michal Klocek
Adds preseterchart example
r246 int numPoints = 10;
for (int x = 0; x <= numPoints; ++x) {
Michal Klocek
Refactor animation to fit line,spline,scatter...
r476 qreal y = qrand() % 100;
Jani Honkonen
rename functions add() -> append()
r796 series0->append(x,y);
series1->append(x,y);
series2->append(x,y);
Michal Klocek
Adds preseterchart example
r246 }
Michal Klocek
Adds chartPresenter example to docs
r482 //![2]
Michal Klocek
Adds preseterchart example
r246
Michal Klocek
Adds chartPresenter example to docs
r482 //![3]
Michal Klocek
Adds preseterchart example
r246 m_series<<series0;
Michal Klocek
Fix compilation of presenter chart
r866 m_titles<< m_chart->title()+": LineChart";
Michal Klocek
Adds preseterchart example
r246 m_series<<series1;
Michal Klocek
Fix compilation of presenter chart
r866 m_titles<< m_chart->title()+": ScatterChart";
Michal Klocek
Adds preseterchart example
r246 m_series<<series2;
Michal Klocek
Fix compilation of presenter chart
r866 m_titles<< m_chart->title()+": SplineChart";
Michal Klocek
Adds area chart animations...
r560 m_series<<series3;
Michal Klocek
Fix compilation of presenter chart
r866 m_titles<< m_chart->title()+": AreaChart";
Michal Klocek
Adds chartPresenter example to docs
r482 //![3]
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571
Michal Klocek
Adds preseterchart example
r246 m_timer.start();
Michal Klocek
Refactor , move dataset legend presentr connections to one place
r871 handleTimeout();
Michal Klocek
Adds preseterchart example
r246 }
ChartView::~ChartView()
{
Michal Klocek
Fix memory leak in presenter example
r257 if(m_series.size()==0) return;
Michal Klocek
Fix compilation of presenter chart
r866 m_chart->removeSeries(m_series.at(m_index));
Michal Klocek
Fixes chart presenter crash on exit
r981 m_series.removeLast(); //remove QAreaSeries instance since they will be deleted when QLineSeries instance is gone
Michal Klocek
Fix memory leak in presenter example
r257 qDeleteAll(m_series);
Michal Klocek
Adds preseterchart example
r246 }
Tero Ahola
Fixed presenter and scatter examples and their documentation.
r1015 //![4]
Michal Klocek
Adds preseterchart example
r246 void ChartView::handleTimeout()
{
if(m_series.size()==0) return;
Michal Klocek
Updates preseter example
r868 if(m_index>=0)
Michal Klocek
Fix compilation of presenter chart
r866 m_chart->removeSeries(m_series.at(m_index));
Michal Klocek
Adds preseterchart example
r246 m_index++;
m_index=m_index%m_series.size();
Michal Klocek
Fix compilation of presenter chart
r866 m_chart->addSeries(m_series.at(m_index));
m_chart->setTitle(m_titles.at(m_index));
Michal Klocek
Adds preseterchart example
r246 }
Tero Ahola
Fixed presenter and scatter examples and their documentation.
r1015 //![4]