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

void QPainterPath::arcTo ( const QRectF rectangle,
qreal  startAngle,
qreal  sweepLength 
)

Creates an arc that occupies the given rectangle, beginning at the specified startAngle and extending sweepLength degrees counter-clockwise.

Angles are specified in degrees. Clockwise arcs can be specified using negative angles.

Note that this function connects the starting point of the arc to the current position if they are not already connected. After the arc has been added, the current position is the last point in arc. To draw a line back to the first point, use the closeSubpath() function.

100% qpainterpath-arcto.png

        QLinearGradient myGradient;
        QPen myPen;

        QPointF center, startPoint;

        QPainterPath myPath;
        myPath.moveTo(center);
        myPath.arcTo(boundingRect, startAngle,
                     sweepLength);

        QPainter painter(this);
        painter.setBrush(myGradient);
        painter.setPen(myPen);
        painter.drawPath(myPath);

See also:
arcMoveTo(), addEllipse(), QPainter::drawArc(), QPainter::drawPie(), {QPainterPath::Composing a QPainterPath}{Composing a QPainterPath}

Definition at line 840 of file qpainterpath.cpp.

References cubicTo(), QRectF::height(), QRectF::isNull(), lineTo(), QRectF::width(), QRectF::x(), and QRectF::y().

Referenced by addRoundRect(), arcTo(), QPainter::drawArc(), QPainter::drawChord(), QPainter::drawPie(), Q3PointArray::makeArc(), and QGraphicsEllipseItem::shape().

{
#ifdef QPP_DEBUG
    printf("QPainterPath::arcTo() (%.2f, %.2f, %.2f, %.2f, angle=%.2f, sweep=%.2f\n",
           rect.x(), rect.y(), rect.width(), rect.height(), startAngle, sweepLength);
#endif
#ifndef QT_NO_DEBUG
    if (qt_is_nan(rect.x()) || qt_is_nan(rect.y()) || qt_is_nan(rect.width()) || qt_is_nan(rect.height())
        || qt_is_nan(startAngle) || qt_is_nan(sweepLength))
        qWarning("QPainterPath::arcTo: Adding arc where a parameter is NaN, results are undefined");
#endif
    if (rect.isNull())
        return;

    ensureData();
    detach();

    int point_count;
    QPointF pts[12];
    QPointF curve_start = qt_curves_for_arc(rect, startAngle, sweepLength, pts, &point_count);

    lineTo(curve_start);
    for (int i=0; i<point_count; i+=3) {
        cubicTo(pts[i].x(), pts[i].y(),
                pts[i+1].x(), pts[i+1].y(),
                pts[i+2].x(), pts[i+2].y());
    }

}


Generated by  Doxygen 1.6.0   Back to index