2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2017 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-04-27 10:05:43 +00:00
|
|
|
#include "piechart.h"
|
|
|
|
#include <QPainter>
|
|
|
|
|
|
|
|
//![0]
|
2011-10-14 08:51:42 +00:00
|
|
|
PieChart::PieChart(QQuickItem *parent)
|
|
|
|
: QQuickPaintedItem(parent)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
//![0]
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//![1]
|
2011-08-30 06:18:20 +00:00
|
|
|
void PieChart::paint(QPainter *painter)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
QPen pen(m_color, 2);
|
|
|
|
painter->setPen(pen);
|
2013-02-12 08:15:25 +00:00
|
|
|
painter->setRenderHints(QPainter::Antialiasing, true);
|
|
|
|
painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
//![1]
|
|
|
|
|