74void QQuickBasicDial::paint(QPainter *painter)
76 if (width() <= 0 || height() <= 0)
81 pen.setCapStyle(Qt::FlatCap);
84 const QRectF bounds = boundingRect();
85 const qreal smallest = qMin(bounds.width(), bounds.height());
86 QRectF rect = QRectF(pen.widthF() / 2.0 + 1, pen.widthF() / 2.0 + 1, smallest - pen.widthF() - 2, smallest - pen.widthF() - 2);
87 rect.moveCenter(bounds.center());
90 if (rect.x() -
int(rect.x()) > 0)
91 rect.setX(qCeil(rect.x()));
92 if (rect.y() -
int(rect.y()) > 0)
93 rect.setY(qCeil(rect.y()));
94 if (rect.width() -
int(rect.width()) > 0)
95 rect.setWidth(qFloor(rect.width()));
96 if (rect.height() -
int(rect.height()) > 0)
97 rect.setHeight(qFloor(rect.height()));
99 painter->setRenderHint(QPainter::Antialiasing);
101 const qreal startAngle = 90. - m_startAngle;
102 const qreal spanAngle = m_progress * (m_startAngle - m_endAngle);
104 path.arcMoveTo(rect, startAngle);
105 path.arcTo(rect, startAngle, spanAngle);
106 painter->drawPath(path);
108 rect.adjust(-pen.widthF() / 2.0, -pen.widthF() / 2.0, pen.widthF() / 2.0, pen.widthF() / 2.0);
110 painter->setPen(pen);
112 path = QPainterPath();
113 path.arcMoveTo(rect, 0);
114 path.arcTo(rect, 0, 360);
115 painter->drawPath(path);