diff --git a/examples/customcolors/mainwindow.cpp b/examples/customcolors/mainwindow.cpp index 6697ff5..5a11b84 100644 --- a/examples/customcolors/mainwindow.cpp +++ b/examples/customcolors/mainwindow.cpp @@ -15,11 +15,11 @@ MainWindow::MainWindow(QWidget *parent) // Here's the set of company's colors used throughout the example m_companyColor1 = "#b90020"; m_companyColor2 = "#6d0013"; - m_companyColor3 = "#d5d5d5"; + m_companyColor3 = "#d5d5f5"; m_companyColor4 = "#fcfcfc"; resize(400, 300); - //setWindowFlags(Qt::FramelessWindowHint); + setWindowFlags(Qt::FramelessWindowHint); // Create chart view m_chartView = new QChartView(this); @@ -40,7 +40,7 @@ MainWindow::MainWindow(QWidget *parent) m_scatter->add(m_line->data()); m_chartView->addSeries(m_scatter); - // Create pie series using color 2; use different fill styles for each pie slice + // Create pie series with different data m_pie = new QPieSeries(); m_pie->add(1.1, "1"); m_pie->add(2.1, "2"); @@ -69,6 +69,7 @@ void MainWindow::customize() chartGradient.setColorAt(1.0, m_companyColor3); m_chartView->setChartBackgroundBrush(chartGradient); m_chartView->setBackgroundBrush(m_companyColor4); + m_chartView->setChartTitleBrush(m_companyColor1); // Customize chart axis QPen color1Pen(m_companyColor1, 4.0); @@ -85,6 +86,7 @@ void MainWindow::customize() m_pie->slices().at(i)->setSlicePen(color1Pen); } + // Calculate new colors to be used on the next update for the series m_companyColor1.setRed((m_companyColor1.red() + 25) % 255); m_companyColor1.setGreen((m_companyColor1.green() + 25) % 255); diff --git a/src/qchart.cpp b/src/qchart.cpp index 83d187d..3633ace 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -140,6 +140,24 @@ void QChart::setChartTitleFont(const QFont& font) m_titleItem->setFont(font); } +/*! + Sets the \a brush used for rendering the title text. +*/ +void QChart::setChartTitleBrush(const QBrush &brush) +{ + createChartTitleItem(); + m_titleItem->setBrush(brush); +} + +/*! + Returns the brush used for rendering the title text. +*/ +QBrush QChart::chartTitleBrush() +{ + createChartTitleItem(); + return m_titleItem->brush(); +} + void QChart::createChartBackgroundItem() { if(!m_backgroundItem) { diff --git a/src/qchart.h b/src/qchart.h index 36734cb..843c9c2 100644 --- a/src/qchart.h +++ b/src/qchart.h @@ -59,6 +59,8 @@ public: void setChartTitle(const QString& title); QString chartTitle() const; void setChartTitleFont(const QFont& font); + void setChartTitleBrush(const QBrush &brush); + QBrush chartTitleBrush(); void setChartBackgroundBrush(const QBrush& brush); void setChartBackgroundPen(const QPen& pen); diff --git a/src/qchartview.cpp b/src/qchartview.cpp index 1ee6fb6..22e5960 100644 --- a/src/qchartview.cpp +++ b/src/qchartview.cpp @@ -158,6 +158,22 @@ void QChartView::setChartTitleFont(const QFont& font) } /*! + Sets the \a brush used for rendering the title text. +*/ +void QChartView::setChartTitleBrush(const QBrush &brush) +{ + m_chart->setChartTitleBrush(brush); +} + +/*! + Returns the brush used for rendering the title text. +*/ +QBrush QChartView::chartTitleBrush() +{ + return m_chart->chartTitleBrush(); +} + +/*! Sets the \a brush that is used for painting the background of the chart area of the QChartView widget. */ void QChartView::setChartBackgroundBrush(const QBrush& brush) diff --git a/src/qchartview.h b/src/qchartview.h index 77f97c9..205c0cc 100644 --- a/src/qchartview.h +++ b/src/qchartview.h @@ -23,7 +23,7 @@ public: //implement from QWidget void resizeEvent(QResizeEvent *event); - + void addSeries(QSeries* series,QChartAxis* axisY=0);// takes series ownership , takes axis ownership void removeSeries(QSeries* series); //returns ownership , deletes axis if no series attached void removeAllSeries(); // deletes series and axis @@ -32,6 +32,8 @@ public: void setChartTitle(const QString& title); QString chartTitle() const; void setChartTitleFont(const QFont& font); + void setChartTitleBrush(const QBrush &brush); + QBrush chartTitleBrush(); void setChartBackgroundBrush(const QBrush& brush); void setChartBackgroundPen(const QPen& pen);