##// END OF EJS Templates
Tuning scatter examples and screens
Tuning scatter examples and screens

File last commit:

r349:7594bc4927de
r398:406174ca742b
Show More
chartview.cpp
59 lines | 1.3 KiB | text/x-c | CppLexer
Michal Klocek
Adds preseterchart example
r246 #include "chartview.h"
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 #include <qlineseries.h>
Michal Klocek
Adds preseterchart example
r246 #include <QTime>
ChartView::ChartView(QWidget* parent):QChartView(parent),
m_index(0)
{
QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout()));
m_timer.setInterval(3000);
QTime now = QTime::currentTime();
qsrand((uint)now.msec());
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 QLineSeries* series0 = new QLineSeries();
Michal Klocek
Adds preseterchart example
r246 QPen blue(Qt::blue);
blue.setWidth(3);
series0->setPen(blue);
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 QLineSeries* series1 = new QLineSeries();
Michal Klocek
Adds preseterchart example
r246 QPen red(Qt::red);
red.setWidth(3);
series1->setPen(red);
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 QLineSeries* series2 = new QLineSeries();
Michal Klocek
Adds preseterchart example
r246 QPen green(Qt::green);
green.setWidth(3);
series2->setPen(green);
int numPoints = 10;
for (int x = 0; x <= numPoints; ++x) {
series0->add(x, qrand() % 100);
series1->add(x, qrand() % 100);
series2->add(x, qrand() % 100);
}
addSeries(series0);
m_series<<series0;
m_series<<series1;
m_series<<series2;
m_timer.start();
}
ChartView::~ChartView()
{
Michal Klocek
Fix memory leak in presenter example
r257 if(m_series.size()==0) return;
removeSeries(m_series.at(m_index));
qDeleteAll(m_series);
Michal Klocek
Adds preseterchart example
r246 }
void ChartView::handleTimeout()
{
if(m_series.size()==0) return;
removeSeries(m_series.at(m_index));
m_index++;
m_index=m_index%m_series.size();
addSeries(m_series.at(m_index));
}