@@ -1,41 +1,42 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chart.h" |
|
21 | #include "chart.h" | |
22 | #include <QChartView> |
|
22 | #include <QChartView> | |
23 | #include <QApplication> |
|
23 | #include <QApplication> | |
24 | #include <QMainWindow> |
|
24 | #include <QMainWindow> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
27 |
|
27 | |||
28 | int main(int argc, char *argv[]) |
|
28 | int main(int argc, char *argv[]) | |
29 | { |
|
29 | { | |
30 | QApplication a(argc, argv); |
|
30 | QApplication a(argc, argv); | |
31 | QMainWindow window; |
|
31 | QMainWindow window; | |
32 | Chart *chart = new Chart; |
|
32 | Chart *chart = new Chart; | |
33 | chart->setTitle("Dynamic spline chart"); |
|
33 | chart->setTitle("Dynamic spline chart"); | |
|
34 | chart->legend()->hide(); | |||
34 | chart->setAnimationOptions(QChart::AllAnimations); |
|
35 | chart->setAnimationOptions(QChart::AllAnimations); | |
35 | QChartView chartView(chart); |
|
36 | QChartView chartView(chart); | |
36 | chartView.setRenderHint(QPainter::Antialiasing); |
|
37 | chartView.setRenderHint(QPainter::Antialiasing); | |
37 | window.setCentralWidget(&chartView); |
|
38 | window.setCentralWidget(&chartView); | |
38 | window.resize(400, 300); |
|
39 | window.resize(400, 300); | |
39 | window.show(); |
|
40 | window.show(); | |
40 | return a.exec(); |
|
41 | return a.exec(); | |
41 | } |
|
42 | } |
@@ -1,122 +1,122 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QLineSeries> |
|
24 | #include <QLineSeries> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
27 |
|
27 | |||
28 | int main(int argc, char *argv[]) |
|
28 | int main(int argc, char *argv[]) | |
29 | { |
|
29 | { | |
30 | QApplication a(argc, argv); |
|
30 | QApplication a(argc, argv); | |
31 |
|
31 | |||
32 | //![1] |
|
32 | //![1] | |
33 | QLineSeries* series = new QLineSeries(); |
|
33 | QLineSeries* series = new QLineSeries(); | |
34 | series->setName("line"); |
|
|||
35 | *series << QPointF(0, 6) << QPointF(2, 4) << QPointF(3, 8) << QPointF(7, 4) << QPointF(10,5); |
|
34 | *series << QPointF(0, 6) << QPointF(2, 4) << QPointF(3, 8) << QPointF(7, 4) << QPointF(10,5); | |
36 | QChart* chart = new QChart(); |
|
35 | QChart* chart = new QChart(); | |
|
36 | chart->legend()->hide(); | |||
37 | chart->addSeries(series); |
|
37 | chart->addSeries(series); | |
38 | //![1] |
|
38 | //![1] | |
39 |
|
39 | |||
40 | //![2] |
|
40 | //![2] | |
41 | // Customize series |
|
41 | // Customize series | |
42 | QPen pen(QRgb(0xfdb157)); |
|
42 | QPen pen(QRgb(0xfdb157)); | |
43 | pen.setWidth(5); |
|
43 | pen.setWidth(5); | |
44 | series->setPen(pen); |
|
44 | series->setPen(pen); | |
45 |
|
45 | |||
46 | // Customize chart title |
|
46 | // Customize chart title | |
47 | QFont font; |
|
47 | QFont font; | |
48 | font.setPixelSize(18); |
|
48 | font.setPixelSize(18); | |
49 | chart->setTitleFont(font); |
|
49 | chart->setTitleFont(font); | |
50 | chart->setTitleBrush(QBrush(Qt::white)); |
|
50 | chart->setTitleBrush(QBrush(Qt::white)); | |
51 | chart->setTitle("Customchart example"); |
|
51 | chart->setTitle("Customchart example"); | |
52 |
|
52 | |||
53 | // Customize chart background |
|
53 | // Customize chart background | |
54 | QLinearGradient backgroundGradient; |
|
54 | QLinearGradient backgroundGradient; | |
55 | backgroundGradient.setStart(QPointF(0,0)); |
|
55 | backgroundGradient.setStart(QPointF(0,0)); | |
56 | backgroundGradient.setFinalStop(QPointF(0,1)); |
|
56 | backgroundGradient.setFinalStop(QPointF(0,1)); | |
57 | backgroundGradient.setColorAt(0.0, QRgb(0xd2d0d1)); |
|
57 | backgroundGradient.setColorAt(0.0, QRgb(0xd2d0d1)); | |
58 | backgroundGradient.setColorAt(1.0, QRgb(0x4c4547)); |
|
58 | backgroundGradient.setColorAt(1.0, QRgb(0x4c4547)); | |
59 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
59 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |
60 | chart->setBackgroundBrush(backgroundGradient); |
|
60 | chart->setBackgroundBrush(backgroundGradient); | |
61 | //![2] |
|
61 | //![2] | |
62 |
|
62 | |||
63 | //![3] |
|
63 | //![3] | |
64 | QAxis* axisX = chart->axisX(); |
|
64 | QAxis* axisX = chart->axisX(); | |
65 | QAxis* axisY = chart->axisY(); |
|
65 | QAxis* axisY = chart->axisY(); | |
66 |
|
66 | |||
67 | // Customize axis label font |
|
67 | // Customize axis label font | |
68 | QFont labelsFont; |
|
68 | QFont labelsFont; | |
69 | labelsFont.setPixelSize(12); |
|
69 | labelsFont.setPixelSize(12); | |
70 | axisX->setLabelsFont(labelsFont); |
|
70 | axisX->setLabelsFont(labelsFont); | |
71 | axisY->setLabelsFont(labelsFont); |
|
71 | axisY->setLabelsFont(labelsFont); | |
72 |
|
72 | |||
73 | // Customize axis colors |
|
73 | // Customize axis colors | |
74 | QPen axisPen(QRgb(0xd18952)); |
|
74 | QPen axisPen(QRgb(0xd18952)); | |
75 | axisPen.setWidth(2); |
|
75 | axisPen.setWidth(2); | |
76 | axisX->setAxisPen(axisPen); |
|
76 | axisX->setAxisPen(axisPen); | |
77 | axisY->setAxisPen(axisPen); |
|
77 | axisY->setAxisPen(axisPen); | |
78 |
|
78 | |||
79 | // Customize axis label colors |
|
79 | // Customize axis label colors | |
80 | QBrush axisBrush(Qt::white); |
|
80 | QBrush axisBrush(Qt::white); | |
81 | axisX->setLabelsBrush(axisBrush); |
|
81 | axisX->setLabelsBrush(axisBrush); | |
82 | axisY->setLabelsBrush(axisBrush); |
|
82 | axisY->setLabelsBrush(axisBrush); | |
83 |
|
83 | |||
84 | // Customize grid lines and shades |
|
84 | // Customize grid lines and shades | |
85 | axisX->setGridLineVisible(false); |
|
85 | axisX->setGridLineVisible(false); | |
86 | axisY->setGridLineVisible(false); |
|
86 | axisY->setGridLineVisible(false); | |
87 | axisY->setShadesPen(Qt::NoPen); |
|
87 | axisY->setShadesPen(Qt::NoPen); | |
88 | axisY->setShadesBrush(QBrush(QRgb(0xa5a2a3))); |
|
88 | axisY->setShadesBrush(QBrush(QRgb(0xa5a2a3))); | |
89 | axisY->setShadesVisible(true); |
|
89 | axisY->setShadesVisible(true); | |
90 | //![3] |
|
90 | //![3] | |
91 |
|
91 | |||
92 | //![4] |
|
92 | //![4] | |
93 | QAxisCategories* categoriesX = chart->axisX()->categories(); |
|
93 | QAxisCategories* categoriesX = chart->axisX()->categories(); | |
94 | categoriesX->insert(1,"low"); |
|
94 | categoriesX->insert(1,"low"); | |
95 | categoriesX->insert(5,"optimal"); |
|
95 | categoriesX->insert(5,"optimal"); | |
96 | categoriesX->insert(10,"high"); |
|
96 | categoriesX->insert(10,"high"); | |
97 |
|
97 | |||
98 | QAxisCategories* categoriesY = chart->axisY()->categories(); |
|
98 | QAxisCategories* categoriesY = chart->axisY()->categories(); | |
99 | categoriesY->insert(1,"slow"); |
|
99 | categoriesY->insert(1,"slow"); | |
100 | categoriesY->insert(5,"med"); |
|
100 | categoriesY->insert(5,"med"); | |
101 | categoriesY->insert(10,"fast"); |
|
101 | categoriesY->insert(10,"fast"); | |
102 |
|
102 | |||
103 | axisX->setRange(0,10); |
|
103 | axisX->setRange(0,10); | |
104 | axisX->setTicksCount(4); |
|
104 | axisX->setTicksCount(4); | |
105 | axisY->setRange(0,10); |
|
105 | axisY->setRange(0,10); | |
106 | axisY->setTicksCount(4); |
|
106 | axisY->setTicksCount(4); | |
107 | //![4] |
|
107 | //![4] | |
108 |
|
108 | |||
109 | //![5] |
|
109 | //![5] | |
110 | QChartView* chartView = new QChartView(chart); |
|
110 | QChartView* chartView = new QChartView(chart); | |
111 | chartView->setRenderHint(QPainter::Antialiasing); |
|
111 | chartView->setRenderHint(QPainter::Antialiasing); | |
112 | //![5] |
|
112 | //![5] | |
113 |
|
113 | |||
114 | //![6] |
|
114 | //![6] | |
115 | QMainWindow window; |
|
115 | QMainWindow window; | |
116 | window.setCentralWidget(chartView); |
|
116 | window.setCentralWidget(chartView); | |
117 | window.resize(400, 300); |
|
117 | window.resize(400, 300); | |
118 | window.show(); |
|
118 | window.show(); | |
119 | //![6] |
|
119 | //![6] | |
120 |
|
120 | |||
121 | return a.exec(); |
|
121 | return a.exec(); | |
122 | } |
|
122 | } |
@@ -1,65 +1,65 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QLineSeries> |
|
24 | #include <QLineSeries> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
27 |
|
27 | |||
28 | int main(int argc, char *argv[]) |
|
28 | int main(int argc, char *argv[]) | |
29 | { |
|
29 | { | |
30 | QApplication a(argc, argv); |
|
30 | QApplication a(argc, argv); | |
31 |
|
31 | |||
32 | //![1] |
|
32 | //![1] | |
33 | QLineSeries* series = new QLineSeries(); |
|
33 | QLineSeries* series = new QLineSeries(); | |
34 | series->setName("line"); |
|
|||
35 | //![1] |
|
34 | //![1] | |
36 |
|
35 | |||
37 | //![2] |
|
36 | //![2] | |
38 | series->append(0, 6); |
|
37 | series->append(0, 6); | |
39 | series->append(2, 4); |
|
38 | series->append(2, 4); | |
40 | series->append(3, 8); |
|
39 | series->append(3, 8); | |
41 | series->append(7, 4); |
|
40 | series->append(7, 4); | |
42 | series->append(10, 5); |
|
41 | series->append(10, 5); | |
43 | *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); |
|
42 | *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); | |
44 | //![2] |
|
43 | //![2] | |
45 |
|
44 | |||
46 | //![3] |
|
45 | //![3] | |
47 | QChart* chart = new QChart(); |
|
46 | QChart* chart = new QChart(); | |
|
47 | chart->legend()->hide(); | |||
48 | chart->addSeries(series); |
|
48 | chart->addSeries(series); | |
49 | chart->setTitle("Simple line chart example"); |
|
49 | chart->setTitle("Simple line chart example"); | |
50 | //![3] |
|
50 | //![3] | |
51 |
|
51 | |||
52 | //![4] |
|
52 | //![4] | |
53 | QChartView* chartView = new QChartView(chart); |
|
53 | QChartView* chartView = new QChartView(chart); | |
54 | chartView->setRenderHint(QPainter::Antialiasing); |
|
54 | chartView->setRenderHint(QPainter::Antialiasing); | |
55 | //![4] |
|
55 | //![4] | |
56 |
|
56 | |||
57 | //![5] |
|
57 | //![5] | |
58 | QMainWindow window; |
|
58 | QMainWindow window; | |
59 | window.setCentralWidget(chartView); |
|
59 | window.setCentralWidget(chartView); | |
60 | window.resize(400, 300); |
|
60 | window.resize(400, 300); | |
61 | window.show(); |
|
61 | window.show(); | |
62 | //![5] |
|
62 | //![5] | |
63 |
|
63 | |||
64 | return a.exec(); |
|
64 | return a.exec(); | |
65 | } |
|
65 | } |
@@ -1,109 +1,111 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "tablewidget.h" |
|
21 | #include "tablewidget.h" | |
22 | #include "customtablemodel.h" |
|
22 | #include "customtablemodel.h" | |
23 | #include <QGridLayout> |
|
23 | #include <QGridLayout> | |
24 | #include <QTableView> |
|
24 | #include <QTableView> | |
25 | #include <QChart> |
|
25 | #include <QChart> | |
26 | #include <QChartView> |
|
26 | #include <QChartView> | |
27 | #include <QLineSeries> |
|
27 | #include <QLineSeries> | |
28 | #include <QVXYModelMapper> |
|
28 | #include <QVXYModelMapper> | |
29 | #include <QHeaderView> |
|
29 | #include <QHeaderView> | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
31 | QTCOMMERCIALCHART_USE_NAMESPACE | |
32 |
|
32 | |||
33 | TableWidget::TableWidget(QWidget *parent) |
|
33 | TableWidget::TableWidget(QWidget *parent) | |
34 | : QWidget(parent) |
|
34 | : QWidget(parent) | |
35 | { |
|
35 | { | |
36 | // create simple model for storing data |
|
36 | // create simple model for storing data | |
37 | // user's table data model |
|
37 | // user's table data model | |
38 | //! [1] |
|
38 | //! [1] | |
39 | CustomTableModel *model = new CustomTableModel; |
|
39 | CustomTableModel *model = new CustomTableModel; | |
40 | //! [1] |
|
40 | //! [1] | |
41 |
|
41 | |||
42 | //! [2] |
|
42 | //! [2] | |
43 | // create table view and add model to it |
|
43 | // create table view and add model to it | |
44 | QTableView *tableView = new QTableView; |
|
44 | QTableView *tableView = new QTableView; | |
45 | tableView->setModel(model); |
|
45 | tableView->setModel(model); | |
46 | tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); |
|
46 | tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); | |
47 | tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch); |
|
47 | tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch); | |
48 | //! [2] |
|
48 | //! [2] | |
49 |
|
49 | |||
50 | //! [3] |
|
50 | //! [3] | |
51 | QChart *chart = new QChart; |
|
51 | QChart *chart = new QChart; | |
52 | chart->setAnimationOptions(QChart::AllAnimations); |
|
52 | chart->setAnimationOptions(QChart::AllAnimations); | |
53 | //! [3] |
|
53 | //! [3] | |
54 |
|
54 | |||
55 | // series 1 |
|
55 | // series 1 | |
56 | //! [4] |
|
56 | //! [4] | |
57 | QLineSeries *series = new QLineSeries; |
|
57 | QLineSeries *series = new QLineSeries; | |
|
58 | series->setName("Line 1"); | |||
58 | QVXYModelMapper *mapper = new QVXYModelMapper(this); |
|
59 | QVXYModelMapper *mapper = new QVXYModelMapper(this); | |
59 | mapper->setXColumn(0); |
|
60 | mapper->setXColumn(0); | |
60 | mapper->setYColumn(1); |
|
61 | mapper->setYColumn(1); | |
61 | mapper->setSeries(series); |
|
62 | mapper->setSeries(series); | |
62 | mapper->setModel(model); |
|
63 | mapper->setModel(model); | |
63 | chart->addSeries(series); |
|
64 | chart->addSeries(series); | |
64 | //! [4] |
|
65 | //! [4] | |
65 |
|
66 | |||
66 | //! [5] |
|
67 | //! [5] | |
67 | // for storing color hex from the series |
|
68 | // for storing color hex from the series | |
68 | QString seriesColorHex = "#000000"; |
|
69 | QString seriesColorHex = "#000000"; | |
69 |
|
70 | |||
70 | // get the color of the series and use it for showing the mapped area |
|
71 | // get the color of the series and use it for showing the mapped area | |
71 | seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper(); |
|
72 | seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper(); | |
72 | model->addMapping(seriesColorHex, QRect(0, 0, 2, model->rowCount())); |
|
73 | model->addMapping(seriesColorHex, QRect(0, 0, 2, model->rowCount())); | |
73 | //! [5] |
|
74 | //! [5] | |
74 |
|
75 | |||
75 |
|
76 | |||
76 | // series 2 |
|
77 | // series 2 | |
77 | //! [6] |
|
78 | //! [6] | |
78 | series = new QLineSeries; |
|
79 | series = new QLineSeries; | |
|
80 | series->setName("Line 2"); | |||
79 |
|
81 | |||
80 | mapper = new QVXYModelMapper(this); |
|
82 | mapper = new QVXYModelMapper(this); | |
81 | mapper->setXColumn(2); |
|
83 | mapper->setXColumn(2); | |
82 | mapper->setYColumn(3); |
|
84 | mapper->setYColumn(3); | |
83 | mapper->setSeries(series); |
|
85 | mapper->setSeries(series); | |
84 | mapper->setModel(model); |
|
86 | mapper->setModel(model); | |
85 | chart->addSeries(series); |
|
87 | chart->addSeries(series); | |
86 | //! [6] |
|
88 | //! [6] | |
87 |
|
89 | |||
88 | //! [7] |
|
90 | //! [7] | |
89 | // get the color of the series and use it for showing the mapped area |
|
91 | // get the color of the series and use it for showing the mapped area | |
90 | seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper(); |
|
92 | seriesColorHex = "#" + QString::number(series->pen().color().rgb(), 16).right(6).toUpper(); | |
91 | model->addMapping(seriesColorHex, QRect(2, 0, 2, model->rowCount())); |
|
93 | model->addMapping(seriesColorHex, QRect(2, 0, 2, model->rowCount())); | |
92 | //! [7] |
|
94 | //! [7] | |
93 |
|
95 | |||
94 | //! [8] |
|
96 | //! [8] | |
95 | QChartView *chartView = new QChartView(chart); |
|
97 | QChartView *chartView = new QChartView(chart); | |
96 | chartView->setRenderHint(QPainter::Antialiasing); |
|
98 | chartView->setRenderHint(QPainter::Antialiasing); | |
97 | chartView->setMinimumSize(640, 480); |
|
99 | chartView->setMinimumSize(640, 480); | |
98 | //! [8] |
|
100 | //! [8] | |
99 |
|
101 | |||
100 | //! [9] |
|
102 | //! [9] | |
101 | // create main layout |
|
103 | // create main layout | |
102 | QGridLayout* mainLayout = new QGridLayout; |
|
104 | QGridLayout* mainLayout = new QGridLayout; | |
103 | mainLayout->addWidget(tableView, 1, 0); |
|
105 | mainLayout->addWidget(tableView, 1, 0); | |
104 | mainLayout->addWidget(chartView, 1, 1); |
|
106 | mainLayout->addWidget(chartView, 1, 1); | |
105 | mainLayout->setColumnStretch(1, 1); |
|
107 | mainLayout->setColumnStretch(1, 1); | |
106 | mainLayout->setColumnStretch(0, 0); |
|
108 | mainLayout->setColumnStretch(0, 0); | |
107 | setLayout(mainLayout); |
|
109 | setLayout(mainLayout); | |
108 | //! [9] |
|
110 | //! [9] | |
109 | } |
|
111 | } |
@@ -1,66 +1,67 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QApplication> |
|
21 | #include <QApplication> | |
22 | #include <QMainWindow> |
|
22 | #include <QMainWindow> | |
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QSplineSeries> |
|
24 | #include <QSplineSeries> | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
27 |
|
27 | |||
28 | int main(int argc, char *argv[]) |
|
28 | int main(int argc, char *argv[]) | |
29 | { |
|
29 | { | |
30 | QApplication a(argc, argv); |
|
30 | QApplication a(argc, argv); | |
31 |
|
31 | |||
32 | //![1] |
|
32 | //![1] | |
33 | QSplineSeries* series = new QSplineSeries(); |
|
33 | QSplineSeries* series = new QSplineSeries(); | |
34 | series->setName("spline"); |
|
34 | series->setName("spline"); | |
35 | //![1] |
|
35 | //![1] | |
36 |
|
36 | |||
37 | //![2] |
|
37 | //![2] | |
38 | series->append(0, 6); |
|
38 | series->append(0, 6); | |
39 | series->append(2, 4); |
|
39 | series->append(2, 4); | |
40 | series->append(3, 8); |
|
40 | series->append(3, 8); | |
41 | series->append(7, 4); |
|
41 | series->append(7, 4); | |
42 | series->append(10, 5); |
|
42 | series->append(10, 5); | |
43 | *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); |
|
43 | *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); | |
44 | //![2] |
|
44 | //![2] | |
45 |
|
45 | |||
46 | //![3] |
|
46 | //![3] | |
47 | QChart* chart = new QChart(); |
|
47 | QChart* chart = new QChart(); | |
|
48 | chart->legend()->hide(); | |||
48 | chart->addSeries(series); |
|
49 | chart->addSeries(series); | |
49 | chart->setTitle("Simple spline chart example"); |
|
50 | chart->setTitle("Simple spline chart example"); | |
50 | chart->axisY()->setRange(0, 10); |
|
51 | chart->axisY()->setRange(0, 10); | |
51 | //![3] |
|
52 | //![3] | |
52 |
|
53 | |||
53 | //![4] |
|
54 | //![4] | |
54 | QChartView* chartView = new QChartView(chart); |
|
55 | QChartView* chartView = new QChartView(chart); | |
55 | chartView->setRenderHint(QPainter::Antialiasing); |
|
56 | chartView->setRenderHint(QPainter::Antialiasing); | |
56 | //![4] |
|
57 | //![4] | |
57 |
|
58 | |||
58 | //![5] |
|
59 | //![5] | |
59 | QMainWindow window; |
|
60 | QMainWindow window; | |
60 | window.setCentralWidget(chartView); |
|
61 | window.setCentralWidget(chartView); | |
61 | window.resize(400, 300); |
|
62 | window.resize(400, 300); | |
62 | window.show(); |
|
63 | window.show(); | |
63 | //![5] |
|
64 | //![5] | |
64 |
|
65 | |||
65 | return a.exec(); |
|
66 | return a.exec(); | |
66 | } |
|
67 | } |
General Comments 0
You need to be logged in to leave comments.
Login now