@@ -5,5 +5,22 | |||||
5 |
|
5 | |||
6 | The example shows how to create simple line chart. |
|
6 | The example shows how to create simple line chart. | |
7 |
|
7 | |||
8 | ... |
|
8 | \image linechart.png | |
|
9 | ||||
|
10 | To create line charts, QLineSeries instance is needed. Here we create two line series and we set the color and width of line. | |||
|
11 | ||||
|
12 | \snippet ../example/linechart/main.cpp 1 | |||
|
13 | ||||
|
14 | We add data to be shown to both series. | |||
|
15 | ||||
|
16 | \snippet ../example/linechart/main.cpp 2 | |||
|
17 | ||||
|
18 | In the end we create QChartView instance, set title, set anti-aliasing and add both series. | |||
|
19 | ||||
|
20 | \snippet ../example/linechart/main.cpp 3 | |||
|
21 | ||||
|
22 | Chart is ready to be shown. | |||
|
23 | ||||
|
24 | \snippet ../example/linechart/main.cpp 4 | |||
|
25 | ||||
9 | */ No newline at end of file |
|
26 | */ |
@@ -11,8 +11,6 int main(int argc, char *argv[]) | |||||
11 | { |
|
11 | { | |
12 | QApplication a(argc, argv); |
|
12 | QApplication a(argc, argv); | |
13 |
|
13 | |||
14 | QMainWindow window; |
|
|||
15 |
|
||||
16 | //![1] |
|
14 | //![1] | |
17 |
|
15 | |||
18 | QLineSeries* series0 = new QLineSeries(); |
|
16 | QLineSeries* series0 = new QLineSeries(); | |
@@ -40,17 +38,20 int main(int argc, char *argv[]) | |||||
40 | series1->add(10,2); |
|
38 | series1->add(10,2); | |
41 | //![2] |
|
39 | //![2] | |
42 | //![3] |
|
40 | //![3] | |
|
41 | QMainWindow window; | |||
43 | QChartView* chartView = new QChartView(&window); |
|
42 | QChartView* chartView = new QChartView(&window); | |
44 |
|
43 | |||
45 | chartView->setRenderHint(QPainter::Antialiasing); |
|
|||
46 | chartView->setChartTitle("Basic line chart example"); |
|
44 | chartView->setChartTitle("Basic line chart example"); | |
|
45 | chartView->setRenderHint(QPainter::Antialiasing); | |||
|
46 | ||||
47 | chartView->addSeries(series0); |
|
47 | chartView->addSeries(series0); | |
48 | chartView->addSeries(series1); |
|
48 | chartView->addSeries(series1); | |
49 | //![3] |
|
49 | //![3] | |
50 |
|
50 | //![4] | ||
51 | window.setCentralWidget(chartView); |
|
51 | window.setCentralWidget(chartView); | |
52 | window.resize(400, 300); |
|
52 | window.resize(400, 300); | |
53 | window.show(); |
|
53 | window.show(); | |
|
54 | //![4] | |||
54 |
|
55 | |||
55 | return a.exec(); |
|
56 | return a.exec(); | |
56 | } |
|
57 | } |
General Comments 0
You need to be logged in to leave comments.
Login now