@@ -5,5 +5,22 | |||
|
5 | 5 | |
|
6 | 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 | 26 | */ No newline at end of file |
@@ -11,8 +11,6 int main(int argc, char *argv[]) | |||
|
11 | 11 | { |
|
12 | 12 | QApplication a(argc, argv); |
|
13 | 13 | |
|
14 | QMainWindow window; | |
|
15 | ||
|
16 | 14 | //![1] |
|
17 | 15 | |
|
18 | 16 | QLineSeries* series0 = new QLineSeries(); |
@@ -40,17 +38,20 int main(int argc, char *argv[]) | |||
|
40 | 38 | series1->add(10,2); |
|
41 | 39 | //![2] |
|
42 | 40 | //![3] |
|
41 | QMainWindow window; | |
|
43 | 42 | QChartView* chartView = new QChartView(&window); |
|
44 | 43 | |
|
45 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
46 | 44 | chartView->setChartTitle("Basic line chart example"); |
|
45 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
46 | ||
|
47 | 47 | chartView->addSeries(series0); |
|
48 | 48 | chartView->addSeries(series1); |
|
49 | 49 | //![3] |
|
50 | ||
|
50 | //![4] | |
|
51 | 51 | window.setCentralWidget(chartView); |
|
52 | 52 | window.resize(400, 300); |
|
53 | 53 | window.show(); |
|
54 | //![4] | |
|
54 | 55 | |
|
55 | 56 | return a.exec(); |
|
56 | 57 | } |
General Comments 0
You need to be logged in to leave comments.
Login now