@@ -2,7 +2,7 | |||||
2 | error( "Couldn't find the examples.pri file!" ) |
|
2 | error( "Couldn't find the examples.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 |
TARGET = c |
|
5 | TARGET = customechart | |
6 | SOURCES += main.cpp |
|
6 | SOURCES += main.cpp | |
7 |
|
7 | |||
8 |
|
8 |
@@ -52,7 +52,7 int main(int argc, char *argv[]) | |||||
52 |
|
52 | |||
53 | //![1] |
|
53 | //![1] | |
54 | QLineSeries* series = new QLineSeries(); |
|
54 | QLineSeries* series = new QLineSeries(); | |
55 |
QPen blue(Qt:: |
|
55 | QPen blue(Qt::yellow); | |
56 | blue.setWidth(3); |
|
56 | blue.setWidth(3); | |
57 | series->setPen(blue); |
|
57 | series->setPen(blue); | |
58 | //![1] |
|
58 | //![1] | |
@@ -62,34 +62,63 int main(int argc, char *argv[]) | |||||
62 | //![3] |
|
62 | //![3] | |
63 | QChart* chart = new QChart(); |
|
63 | QChart* chart = new QChart(); | |
64 | chart->addSeries(series); |
|
64 | chart->addSeries(series); | |
65 |
chart->setTitle(" |
|
65 | chart->setTitle("Simple customchart example"); | |
66 | //![3] |
|
66 | //![3] | |
67 | //![4] |
|
67 | //![4] | |
68 | QFont font; |
|
68 | QFont font; | |
69 | font.setPixelSize(18); |
|
69 | font.setPixelSize(18); | |
70 | chart->setTitleFont(font); |
|
70 | chart->setTitleFont(font); | |
71 |
chart->setTitleBrush(Qt:: |
|
71 | chart->setTitleBrush(Qt::yellow); | |
72 |
|
72 | |||
73 | QLinearGradient backgroundGradient; |
|
73 | QLinearGradient backgroundGradient; | |
74 |
backgroundGradient.set |
|
74 | backgroundGradient.setStart(QPointF(0,0)); | |
75 |
backgroundGradient.set |
|
75 | backgroundGradient.setFinalStop(QPointF(0,1)); | |
|
76 | backgroundGradient.setColorAt(0.0, 0x3cc63c); | |||
|
77 | backgroundGradient.setColorAt(1.0, 0x26f626); | |||
76 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); |
|
78 | backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode); | |
77 | chart->setBackgroundBrush(backgroundGradient); |
|
79 | chart->setBackgroundBrush(backgroundGradient); | |
78 |
|
||||
79 | QPen black(Qt::black); |
|
|||
80 | chart->axisX()->setGridLinePen(black); |
|
|||
81 | chart->axisX()->setAxisPen(black); |
|
|||
82 | chart->axisY()->setGridLinePen(black); |
|
|||
83 | chart->axisY()->setAxisPen(black); |
|
|||
84 | //![4] |
|
80 | //![4] | |
85 | //![5] |
|
81 | //![5] | |
|
82 | QPen black(Qt::black); | |||
|
83 | QChartAxis* axisX = chart->axisX(); | |||
|
84 | QChartAxis* axisY = chart->axisY(); | |||
|
85 | ||||
|
86 | axisX->setAxisPen(black); | |||
|
87 | axisY->setAxisPen(black); | |||
|
88 | axisX->setGridLineVisible(false); | |||
|
89 | axisY->setGridLineVisible(false); | |||
|
90 | ||||
|
91 | axisY->setShadesPen(Qt::NoPen); | |||
|
92 | axisY->setShadesOpacity(0.5); | |||
|
93 | axisY->setShadesBrush(Qt::white); | |||
|
94 | axisY->setShadesVisible(true); | |||
|
95 | //![5] | |||
|
96 | //![6] | |||
|
97 | QChartAxisCategories* categoriesX = chart->axisX()->categories(); | |||
|
98 | categoriesX->insert(1,"low"); | |||
|
99 | categoriesX->insert(5,"optimal"); | |||
|
100 | categoriesX->insert(10,"high"); | |||
|
101 | ||||
|
102 | QChartAxisCategories* categoriesY = chart->axisY()->categories(); | |||
|
103 | categoriesY->insert(1,"slow"); | |||
|
104 | categoriesY->insert(5,"med"); | |||
|
105 | categoriesY->insert(10,"fast"); | |||
|
106 | //![6] | |||
|
107 | //![7] | |||
|
108 | axisX->setRange(0,10); | |||
|
109 | axisX->setTicksCount(4); | |||
|
110 | axisY->setRange(0,10); | |||
|
111 | axisY->setTicksCount(4); | |||
|
112 | //![7] | |||
|
113 | //![8] | |||
86 | QChartView* chartView = new QChartView(chart); |
|
114 | QChartView* chartView = new QChartView(chart); | |
87 | chartView->setRenderHint(QPainter::Antialiasing); |
|
115 | chartView->setRenderHint(QPainter::Antialiasing); | |
88 |
//![ |
|
116 | //![8] | |
|
117 | //![9] | |||
89 | QMainWindow window; |
|
118 | QMainWindow window; | |
90 | window.setCentralWidget(chartView); |
|
119 | window.setCentralWidget(chartView); | |
91 | window.resize(400, 300); |
|
120 | window.resize(400, 300); | |
92 | window.show(); |
|
121 | window.show(); | |
93 |
//![ |
|
122 | //![9] | |
94 | return a.exec(); |
|
123 | return a.exec(); | |
95 | } |
|
124 | } |
@@ -1,11 +1,9 | |||||
1 | TEMPLATE = subdirs |
|
1 | TEMPLATE = subdirs | |
2 | SUBDIRS += \ |
|
2 | SUBDIRS += \ | |
3 | areachart \ |
|
3 | areachart \ | |
4 | #axischart \ |
|
|||
5 | barchart \ |
|
4 | barchart \ | |
6 | #chartview \ |
|
5 | #chartview \ | |
7 |
c |
|
6 | customchart \ | |
8 | #customcolors \ |
|
|||
9 | #dynamiclinechart \ |
|
7 | #dynamiclinechart \ | |
10 | #ekgchart \ |
|
8 | #ekgchart \ | |
11 | #gdpbarchart \ |
|
9 | #gdpbarchart \ |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now