|
1 | NO CONTENT: new file 100644, binary diff hidden |
@@ -1,7 +1,9 | |||
|
1 | 1 | /*! |
|
2 | 2 | \example examples/scatterinteractions |
|
3 | 3 | \title ScatterChart Example |
|
4 | 4 | \subtitle |
|
5 | 5 | |
|
6 | 6 | The example shows how to create simple scatter chart and how to interact with the chart. |
|
7 | ||
|
8 | \image examples_scatterinteractions.png | |
|
7 | 9 | */ |
@@ -1,57 +1,58 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 |
#include " |
|
|
22 | #include <QChartView> | |
|
21 | #include "chartview.h" | |
|
23 | 22 | |
|
24 | 23 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
25 | 24 | |
|
26 |
|
|
|
27 | : QMainWindow(parent) | |
|
25 | ChartView::ChartView(QWidget *parent) | |
|
26 | : QChartView(new QChart(), parent), | |
|
27 | m_scatter(0), | |
|
28 | m_scatter2(0) | |
|
28 | 29 | { |
|
29 | QChart *chart = new QChart(); | |
|
30 | chart->setTitle("Click to remove scatter point"); | |
|
30 | setRenderHint(QPainter::Antialiasing); | |
|
31 | ||
|
32 | chart()->setTitle("Click to interact with scatter points"); | |
|
31 | 33 | |
|
32 | 34 | m_scatter = new QScatterSeries(); |
|
33 | 35 | for(qreal x(0.5); x <= 4.0; x += 0.5) { |
|
34 | 36 | for(qreal y(0.5); y <= 4.0; y += 0.5) { |
|
35 | 37 | *m_scatter << QPointF(x, y); |
|
36 | 38 | } |
|
37 | 39 | } |
|
40 | m_scatter2 = new QScatterSeries(); | |
|
38 | 41 | |
|
39 | chart->addSeries(m_scatter); | |
|
40 | chart->axisX()->setRange(0, 4.5); | |
|
41 |
chart->axis |
|
|
42 | chart()->addSeries(m_scatter2); | |
|
43 | chart()->addSeries(m_scatter); | |
|
44 | chart()->axisX()->setRange(0, 4.5); | |
|
45 | chart()->axisY()->setRange(0, 4.5); | |
|
42 | 46 | |
|
43 | 47 | connect(m_scatter, SIGNAL(clicked(QPointF)), this, SLOT(handleClickedPoint(QPointF))); |
|
44 | ||
|
45 | QChartView *chartView = new QChartView(chart); | |
|
46 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
47 | setCentralWidget(chartView); | |
|
48 | 48 | } |
|
49 | 49 | |
|
50 | MainWindow::~MainWindow() | |
|
50 | ChartView::~ChartView() | |
|
51 | 51 | { |
|
52 | 52 | } |
|
53 | 53 | |
|
54 |
void |
|
|
54 | void ChartView::handleClickedPoint(const QPointF& point) | |
|
55 | 55 | { |
|
56 | 56 | m_scatter->remove(point); |
|
57 | m_scatter2->append(point); | |
|
57 | 58 | } |
@@ -1,47 +1,46 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #ifndef MAINWINDOW_H |
|
22 | 22 | #define MAINWINDOW_H |
|
23 | 23 | |
|
24 | #include <QtGui/QMainWindow> | |
|
25 |
#include < |
|
|
26 |
#include < |
|
|
24 | #include <QChartGlobal> | |
|
25 | #include <QChartView> | |
|
26 | #include <QScatterSeries> | |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | 29 | |
|
30 |
class |
|
|
30 | class ChartView : public QChartView | |
|
31 | 31 | { |
|
32 | 32 | Q_OBJECT |
|
33 | 33 | |
|
34 | 34 | public: |
|
35 |
|
|
|
36 |
~ |
|
|
35 | ChartView(QWidget *parent = 0); | |
|
36 | ~ChartView(); | |
|
37 | 37 | |
|
38 | 38 | private Q_SLOTS: |
|
39 | 39 | void handleClickedPoint(const QPointF& point); |
|
40 | 40 | |
|
41 | 41 | private: |
|
42 | 42 | QScatterSeries *m_scatter; |
|
43 | 43 | QScatterSeries *m_scatter2; |
|
44 | QScatterSeries *m_scatter3; | |
|
45 | 44 | }; |
|
46 | 45 | |
|
47 | 46 | #endif // MAINWINDOW_H |
@@ -1,32 +1,35 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include <QtGui/QApplication> |
|
22 |
#include |
|
|
22 | #include <QMainWindow> | |
|
23 | #include "chartview.h" | |
|
23 | 24 | |
|
24 | 25 | int main(int argc, char *argv[]) |
|
25 | 26 | { |
|
26 | 27 | QApplication a(argc, argv); |
|
27 | MainWindow w; | |
|
28 | w.resize(400, 300); | |
|
29 | w.show(); | |
|
28 | QMainWindow window; | |
|
29 | ChartView chartView(&window); | |
|
30 | window.setCentralWidget(&chartView); | |
|
31 | window.resize(400, 300); | |
|
32 | window.show(); | |
|
30 | 33 | |
|
31 | 34 | return a.exec(); |
|
32 | 35 | } |
General Comments 0
You need to be logged in to leave comments.
Login now