##// END OF EJS Templates
Modified scientific theme
Modified scientific theme

File last commit:

r486:7ab45bf9f776
r523:768ce5aee641
Show More
mainwindow.cpp
54 lines | 1.4 KiB | text/x-c | CppLexer
Tero Ahola
Clicked, remove and clear to QScatterSeries
r394 #include "mainwindow.h"
#include <qchartglobal.h>
#include <qchartview.h>
#include <QDebug>
QTCOMMERCIALCHART_USE_NAMESPACE
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
resize(400, 300);
setWindowFlags(Qt::FramelessWindowHint);
QChartView *chartView = new QChartView(this);
chartView->setChartTitle("Click to play with points");
chartView->setRenderHint(QPainter::Antialiasing);
setCentralWidget(chartView);
m_scatter = new QScatterSeries();
for(qreal x(0.5); x <= 5.0; x += 0.5) {
for(qreal y(0.5); y <= 5.0; y += 0.5) {
*m_scatter << QPointF(x, y);
}
}
chartView->addSeries(m_scatter);
// Add two more series
m_scatter2 = new QScatterSeries();
chartView->addSeries(m_scatter2);
m_scatter3 = new QScatterSeries();
chartView->addSeries(m_scatter3);
connect(m_scatter, SIGNAL(clicked(QPointF)), this, SLOT(clickPoint(QPointF)));
}
MainWindow::~MainWindow()
{
}
void MainWindow::clickPoint(QPointF coordinate)
{
// Remove the clicked point from the series and add points to the two other series we have
Michal Klocek
Refactor scatter chart to fit the other classes...
r470 //TODO: fix me
/*
Tero Ahola
Clicked, remove and clear to QScatterSeries
r394 int index = m_scatter->closestPoint(coordinate);
QPointF point = m_scatter->data().at(index);
Q_ASSERT(m_scatter->removeAt(index));
point.rx() += 0.25;
point.ry() += 0.25;
*m_scatter2 << point;
point.ry() -= 0.25;
*m_scatter3 << point;
Michal Klocek
Refactor scatter chart to fit the other classes...
r470 */
Tero Ahola
Clicked, remove and clear to QScatterSeries
r394 }