##// END OF EJS Templates
Chart title font color
Tero Ahola -
r495:5c5df42e5e34
parent child
Show More
@@ -15,11 +15,11 MainWindow::MainWindow(QWidget *parent)
15 // Here's the set of company's colors used throughout the example
15 // Here's the set of company's colors used throughout the example
16 m_companyColor1 = "#b90020";
16 m_companyColor1 = "#b90020";
17 m_companyColor2 = "#6d0013";
17 m_companyColor2 = "#6d0013";
18 m_companyColor3 = "#d5d5d5";
18 m_companyColor3 = "#d5d5f5";
19 m_companyColor4 = "#fcfcfc";
19 m_companyColor4 = "#fcfcfc";
20
20
21 resize(400, 300);
21 resize(400, 300);
22 //setWindowFlags(Qt::FramelessWindowHint);
22 setWindowFlags(Qt::FramelessWindowHint);
23
23
24 // Create chart view
24 // Create chart view
25 m_chartView = new QChartView(this);
25 m_chartView = new QChartView(this);
@@ -40,7 +40,7 MainWindow::MainWindow(QWidget *parent)
40 m_scatter->add(m_line->data());
40 m_scatter->add(m_line->data());
41 m_chartView->addSeries(m_scatter);
41 m_chartView->addSeries(m_scatter);
42
42
43 // Create pie series using color 2; use different fill styles for each pie slice
43 // Create pie series with different data
44 m_pie = new QPieSeries();
44 m_pie = new QPieSeries();
45 m_pie->add(1.1, "1");
45 m_pie->add(1.1, "1");
46 m_pie->add(2.1, "2");
46 m_pie->add(2.1, "2");
@@ -69,6 +69,7 void MainWindow::customize()
69 chartGradient.setColorAt(1.0, m_companyColor3);
69 chartGradient.setColorAt(1.0, m_companyColor3);
70 m_chartView->setChartBackgroundBrush(chartGradient);
70 m_chartView->setChartBackgroundBrush(chartGradient);
71 m_chartView->setBackgroundBrush(m_companyColor4);
71 m_chartView->setBackgroundBrush(m_companyColor4);
72 m_chartView->setChartTitleBrush(m_companyColor1);
72
73
73 // Customize chart axis
74 // Customize chart axis
74 QPen color1Pen(m_companyColor1, 4.0);
75 QPen color1Pen(m_companyColor1, 4.0);
@@ -85,6 +86,7 void MainWindow::customize()
85 m_pie->slices().at(i)->setSlicePen(color1Pen);
86 m_pie->slices().at(i)->setSlicePen(color1Pen);
86 }
87 }
87
88
89
88 // Calculate new colors to be used on the next update for the series
90 // Calculate new colors to be used on the next update for the series
89 m_companyColor1.setRed((m_companyColor1.red() + 25) % 255);
91 m_companyColor1.setRed((m_companyColor1.red() + 25) % 255);
90 m_companyColor1.setGreen((m_companyColor1.green() + 25) % 255);
92 m_companyColor1.setGreen((m_companyColor1.green() + 25) % 255);
@@ -140,6 +140,24 void QChart::setChartTitleFont(const QFont& font)
140 m_titleItem->setFont(font);
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 void QChart::createChartBackgroundItem()
161 void QChart::createChartBackgroundItem()
144 {
162 {
145 if(!m_backgroundItem) {
163 if(!m_backgroundItem) {
@@ -59,6 +59,8 public:
59 void setChartTitle(const QString& title);
59 void setChartTitle(const QString& title);
60 QString chartTitle() const;
60 QString chartTitle() const;
61 void setChartTitleFont(const QFont& font);
61 void setChartTitleFont(const QFont& font);
62 void setChartTitleBrush(const QBrush &brush);
63 QBrush chartTitleBrush();
62 void setChartBackgroundBrush(const QBrush& brush);
64 void setChartBackgroundBrush(const QBrush& brush);
63 void setChartBackgroundPen(const QPen& pen);
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 Sets the \a brush that is used for painting the background of the chart area of the QChartView widget.
177 Sets the \a brush that is used for painting the background of the chart area of the QChartView widget.
162 */
178 */
163 void QChartView::setChartBackgroundBrush(const QBrush& brush)
179 void QChartView::setChartBackgroundBrush(const QBrush& brush)
@@ -23,7 +23,7 public:
23
23
24 //implement from QWidget
24 //implement from QWidget
25 void resizeEvent(QResizeEvent *event);
25 void resizeEvent(QResizeEvent *event);
26
26
27 void addSeries(QSeries* series,QChartAxis* axisY=0);// takes series ownership , takes axis ownership
27 void addSeries(QSeries* series,QChartAxis* axisY=0);// takes series ownership , takes axis ownership
28 void removeSeries(QSeries* series); //returns ownership , deletes axis if no series attached
28 void removeSeries(QSeries* series); //returns ownership , deletes axis if no series attached
29 void removeAllSeries(); // deletes series and axis
29 void removeAllSeries(); // deletes series and axis
@@ -32,6 +32,8 public:
32 void setChartTitle(const QString& title);
32 void setChartTitle(const QString& title);
33 QString chartTitle() const;
33 QString chartTitle() const;
34 void setChartTitleFont(const QFont& font);
34 void setChartTitleFont(const QFont& font);
35 void setChartTitleBrush(const QBrush &brush);
36 QBrush chartTitleBrush();
35 void setChartBackgroundBrush(const QBrush& brush);
37 void setChartBackgroundBrush(const QBrush& brush);
36 void setChartBackgroundPen(const QPen& pen);
38 void setChartBackgroundPen(const QPen& pen);
37
39
General Comments 0
You need to be logged in to leave comments. Login now