Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

void QPainter::drawPie ( const QRectF rectangle,
int  startAngle,
int  spanAngle 
) [inherited]

Draws a pie defined by the given rectangle, startAngle and and spanAngle.

The pie is filled with the current brush().

The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

100% qpainter-pie.png

        QRectF rectangle(10.0, 20.0, 80.0, 60.0);
        int startAngle = 30 * 16;
        int spanAngle = 120 * 16;

        QPainter painter(this);
        painter.drawPie(rectangle, startAngle, spanAngle);

See also:
drawEllipse(), drawChord(), {The Coordinate System}

Definition at line 3388 of file qpainter.cpp.

References QPainterPath::arcTo(), QRectF::center(), QPainterPath::closeSubpath(), QPainter::drawPath(), QRectF::height(), QPainter::isActive(), QPainterPath::moveTo(), QRectF::normalized(), QRectF::width(), QRectF::x(), and QRectF::y().

Referenced by Q3Painter::drawPie(), QPainter::drawPie(), Q3CanvasEllipse::drawShape(), QPicture::exec(), and QGraphicsEllipseItem::paint().

{
#ifdef QT_DEBUG_DRAW
    if (qt_show_painter_debug_output)
        printf("QPainter::drawPie(), [%.2f,%.2f,%.2f,%.2f], angle=%d, sweep=%d\n",
           r.x(), r.y(), r.width(), r.height(), a/16, alen/16);
#endif

    if (!isActive())
        return;
    Q_D(QPainter);
    d->updateState(d->state);

    if (a > (360*16)) {
        a = a % (360*16);
    } else if (a < 0) {
        a = a % (360*16);
        if (a < 0) a += (360*16);
    }

    QRectF rect = r.normalized();

    QPainterPath path;
    path.moveTo(rect.center());
    path.arcTo(rect.x(), rect.y(), rect.width(), rect.height(), a/16.0, alen/16.0);
    path.closeSubpath();
    drawPath(path);

}


Generated by  Doxygen 1.6.0   Back to index