mainwindow.cpp
38 lines
| 958 B
| text/x-c
|
CppLexer
Tero Ahola
|
r394 | #include "mainwindow.h" | ||
#include <qchartglobal.h> | ||||
#include <qchartview.h> | ||||
Michal Klocek
|
r541 | #include <qchartaxis.h> | ||
Tero Ahola
|
r394 | #include <QDebug> | ||
QTCOMMERCIALCHART_USE_NAMESPACE | ||||
MainWindow::MainWindow(QWidget *parent) | ||||
: QMainWindow(parent) | ||||
{ | ||||
QChartView *chartView = new QChartView(this); | ||||
Michal Klocek
|
r541 | chartView->setChartTitle("Click to remove scatter point"); | ||
Tero Ahola
|
r394 | chartView->setRenderHint(QPainter::Antialiasing); | ||
setCentralWidget(chartView); | ||||
m_scatter = new QScatterSeries(); | ||||
Michal Klocek
|
r536 | for(qreal x(0.5); x <= 4.0; x += 0.5) { | ||
for(qreal y(0.5); y <= 4.0; y += 0.5) { | ||||
Tero Ahola
|
r394 | *m_scatter << QPointF(x, y); | ||
} | ||||
} | ||||
Michal Klocek
|
r541 | chartView->addSeries(m_scatter); | ||
chartView->axisX()->setRange(0,4.5); | ||||
chartView->axisY()->setRange(0,4.5); | ||||
Tero Ahola
|
r394 | |||
Michal Klocek
|
r541 | connect(m_scatter, SIGNAL(clicked(const QPointF&)), this, SLOT(handleClickedPoint(const QPointF&))); | ||
Tero Ahola
|
r394 | } | ||
MainWindow::~MainWindow() | ||||
{ | ||||
} | ||||
Michal Klocek
|
r541 | void MainWindow::handleClickedPoint(const QPointF& point) | ||
Tero Ahola
|
r394 | { | ||
Michal Klocek
|
r541 | m_scatter->remove(point); | ||
Tero Ahola
|
r394 | } | ||