@@ -1,70 +1,61 | |||||
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 | //![1] |
|
31 | //![1] | |
32 |
QLineSeries* series |
|
32 | QLineSeries* series = new QLineSeries(); | |
33 | QPen blue(Qt::blue); |
|
|||
34 | blue.setWidth(3); |
|
|||
35 | series0->setPen(blue); |
|
|||
36 |
|
||||
37 | QLineSeries* series1 = new QLineSeries(); |
|
|||
38 | QPen red(Qt::red); |
|
33 | QPen red(Qt::red); | |
39 | red.setWidth(3); |
|
34 | red.setWidth(3); | |
40 |
series |
|
35 | series->setPen(red); | |
41 | //![1] |
|
36 | //![1] | |
42 |
|
||||
43 | //![2] |
|
37 | //![2] | |
44 |
series |
|
38 | series->append(0, 6); | |
45 |
series |
|
39 | series->append(2, 4); | |
46 |
series |
|
40 | series->append(3, 8); | |
47 |
series |
|
41 | series->append(7, 4); | |
48 |
series |
|
42 | series->append(10, 5); | |
49 |
|
43 | *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); | ||
50 | *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10, 2); |
|
|||
51 | //![2] |
|
44 | //![2] | |
52 | //![3] |
|
45 | //![3] | |
53 | QChart* chart = new QChart(); |
|
46 | QChart* chart = new QChart(); | |
54 |
|
47 | chart->addSeries(series); | ||
55 | chart->addSeries(series0); |
|
|||
56 | chart->addSeries(series1); |
|
|||
57 | chart->setTitle("Simple line chart example"); |
|
48 | chart->setTitle("Simple line chart example"); | |
58 | //![3] |
|
49 | //![3] | |
59 | //![4] |
|
50 | //![4] | |
60 | QChartView* chartView = new QChartView(chart); |
|
51 | QChartView* chartView = new QChartView(chart); | |
61 | chartView->setRenderHint(QPainter::Antialiasing); |
|
52 | chartView->setRenderHint(QPainter::Antialiasing); | |
62 | //![4] |
|
53 | //![4] | |
63 | //![5] |
|
54 | //![5] | |
64 | QMainWindow window; |
|
55 | QMainWindow window; | |
65 | window.setCentralWidget(chartView); |
|
56 | window.setCentralWidget(chartView); | |
66 | window.resize(400, 300); |
|
57 | window.resize(400, 300); | |
67 | window.show(); |
|
58 | window.show(); | |
68 | //![5] |
|
59 | //![5] | |
69 | return a.exec(); |
|
60 | return a.exec(); | |
70 | } |
|
61 | } |
General Comments 0
You need to be logged in to leave comments.
Login now