piechart.cpp Example File | Qt 4.8 (original) (raw)
declarative/tutorials/extending/chapter2-methods/piechart.cpp
#include "piechart.h" #include #include
PieChart::PieChart(QDeclarativeItem *parent) : QDeclarativeItem(parent) {
setFlag([QGraphicsItem](qgraphicsitem.html)::ItemHasNoContents, false);}
QString PieChart::name() const { return m_name; }
void PieChart::setName(const QString &name) { m_name = name; }
QColor PieChart::color() const { return m_color; }
void PieChart::setColor(const QColor &color) { m_color = color; }
void PieChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { QPen pen(m_color, 2); painter->setPen(pen); painter->setRenderHints(QPainter::Antialiasing, true); painter->drawPie(boundingRect(), 90 * 16, 290 * 16); }
void PieChart::clearChart() { setColor(QColor(Qt::transparent)); update();
emit chartCleared();}
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.