@@ -15,11 +15,11 MainWindow::MainWindow(QWidget *parent) | |||
|
15 | 15 | // Here's the set of company's colors used throughout the example |
|
16 | 16 | m_companyColor1 = "#b90020"; |
|
17 | 17 | m_companyColor2 = "#6d0013"; |
|
18 |
m_companyColor3 = "#d5d5 |
|
|
18 | m_companyColor3 = "#d5d5f5"; | |
|
19 | 19 | m_companyColor4 = "#fcfcfc"; |
|
20 | 20 | |
|
21 | 21 | resize(400, 300); |
|
22 |
|
|
|
22 | setWindowFlags(Qt::FramelessWindowHint); | |
|
23 | 23 | |
|
24 | 24 | // Create chart view |
|
25 | 25 | m_chartView = new QChartView(this); |
@@ -40,7 +40,7 MainWindow::MainWindow(QWidget *parent) | |||
|
40 | 40 | m_scatter->add(m_line->data()); |
|
41 | 41 | m_chartView->addSeries(m_scatter); |
|
42 | 42 | |
|
43 |
// Create pie series |
|
|
43 | // Create pie series with different data | |
|
44 | 44 | m_pie = new QPieSeries(); |
|
45 | 45 | m_pie->add(1.1, "1"); |
|
46 | 46 | m_pie->add(2.1, "2"); |
@@ -69,6 +69,7 void MainWindow::customize() | |||
|
69 | 69 | chartGradient.setColorAt(1.0, m_companyColor3); |
|
70 | 70 | m_chartView->setChartBackgroundBrush(chartGradient); |
|
71 | 71 | m_chartView->setBackgroundBrush(m_companyColor4); |
|
72 | m_chartView->setChartTitleBrush(m_companyColor1); | |
|
72 | 73 | |
|
73 | 74 | // Customize chart axis |
|
74 | 75 | QPen color1Pen(m_companyColor1, 4.0); |
@@ -85,6 +86,7 void MainWindow::customize() | |||
|
85 | 86 | m_pie->slices().at(i)->setSlicePen(color1Pen); |
|
86 | 87 | } |
|
87 | 88 | |
|
89 | ||
|
88 | 90 | // Calculate new colors to be used on the next update for the series |
|
89 | 91 | m_companyColor1.setRed((m_companyColor1.red() + 25) % 255); |
|
90 | 92 | m_companyColor1.setGreen((m_companyColor1.green() + 25) % 255); |
@@ -140,6 +140,24 void QChart::setChartTitleFont(const QFont& font) | |||
|
140 | 140 | m_titleItem->setFont(font); |
|
141 | 141 | } |
|
142 | 142 | |
|
143 | /*! | |
|
144 | Sets the \a brush used for rendering the title text. | |
|
145 | */ | |
|
146 | void QChart::setChartTitleBrush(const QBrush &brush) | |
|
147 | { | |
|
148 | createChartTitleItem(); | |
|
149 | m_titleItem->setBrush(brush); | |
|
150 | } | |
|
151 | ||
|
152 | /*! | |
|
153 | Returns the brush used for rendering the title text. | |
|
154 | */ | |
|
155 | QBrush QChart::chartTitleBrush() | |
|
156 | { | |
|
157 | createChartTitleItem(); | |
|
158 | return m_titleItem->brush(); | |
|
159 | } | |
|
160 | ||
|
143 | 161 | void QChart::createChartBackgroundItem() |
|
144 | 162 | { |
|
145 | 163 | if(!m_backgroundItem) { |
@@ -59,6 +59,8 public: | |||
|
59 | 59 | void setChartTitle(const QString& title); |
|
60 | 60 | QString chartTitle() const; |
|
61 | 61 | void setChartTitleFont(const QFont& font); |
|
62 | void setChartTitleBrush(const QBrush &brush); | |
|
63 | QBrush chartTitleBrush(); | |
|
62 | 64 | void setChartBackgroundBrush(const QBrush& brush); |
|
63 | 65 | void setChartBackgroundPen(const QPen& pen); |
|
64 | 66 |
@@ -158,6 +158,22 void QChartView::setChartTitleFont(const QFont& font) | |||
|
158 | 158 | } |
|
159 | 159 | |
|
160 | 160 | /*! |
|
161 | Sets the \a brush used for rendering the title text. | |
|
162 | */ | |
|
163 | void QChartView::setChartTitleBrush(const QBrush &brush) | |
|
164 | { | |
|
165 | m_chart->setChartTitleBrush(brush); | |
|
166 | } | |
|
167 | ||
|
168 | /*! | |
|
169 | Returns the brush used for rendering the title text. | |
|
170 | */ | |
|
171 | QBrush QChartView::chartTitleBrush() | |
|
172 | { | |
|
173 | return m_chart->chartTitleBrush(); | |
|
174 | } | |
|
175 | ||
|
176 | /*! | |
|
161 | 177 | Sets the \a brush that is used for painting the background of the chart area of the QChartView widget. |
|
162 | 178 | */ |
|
163 | 179 | void QChartView::setChartBackgroundBrush(const QBrush& brush) |
@@ -23,7 +23,7 public: | |||
|
23 | 23 | |
|
24 | 24 | //implement from QWidget |
|
25 | 25 | void resizeEvent(QResizeEvent *event); |
|
26 | ||
|
26 | ||
|
27 | 27 | void addSeries(QSeries* series,QChartAxis* axisY=0);// takes series ownership , takes axis ownership |
|
28 | 28 | void removeSeries(QSeries* series); //returns ownership , deletes axis if no series attached |
|
29 | 29 | void removeAllSeries(); // deletes series and axis |
@@ -32,6 +32,8 public: | |||
|
32 | 32 | void setChartTitle(const QString& title); |
|
33 | 33 | QString chartTitle() const; |
|
34 | 34 | void setChartTitleFont(const QFont& font); |
|
35 | void setChartTitleBrush(const QBrush &brush); | |
|
36 | QBrush chartTitleBrush(); | |
|
35 | 37 | void setChartBackgroundBrush(const QBrush& brush); |
|
36 | 38 | void setChartBackgroundPen(const QPen& pen); |
|
37 | 39 |
General Comments 0
You need to be logged in to leave comments.
Login now