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

void QPainterPath::addPolygon ( const QPolygonF polygon  ) 

Adds the given polygon to the path as an (unclosed) subpath.

Note that the current position after the polygon has been added, is the last point in polygon. To draw a line back to the first point, use the closeSubpath() function.

100% qpainterpath-addpolygon.png doc/src/snippets/code/src_gui_painting_qpainterpath.cpp 4

See also:
lineTo(), {QPainterPath::Composing a QPainterPath}{Composing a QPainterPath}

Definition at line 992 of file qpainterpath.cpp.

References QVector< T >::at(), QVector< T >::first(), QVector< T >::isEmpty(), moveTo(), QVector< T >::size(), QPointF::x(), and QPointF::y().

Referenced by QGraphicsItem::collidesWithPath(), QCommonStyle::drawControl(), QPolygon::intersected(), QPolygonF::intersected(), QGraphicsView::items(), QGraphicsScene::items(), QGraphicsView::mouseMoveEvent(), QGraphicsView::render(), Arrow::shape(), QPolygonF::subtracted(), QPolygon::subtracted(), QPolygon::united(), and QPolygonF::united().

{
    if (polygon.isEmpty())
        return;

    ensureData();
    detach();

    d_func()->elements.reserve(d_func()->elements.size() + polygon.size());

    moveTo(polygon.first());
    for (int i=1; i<polygon.size(); ++i) {
        Element elm = { polygon.at(i).x(), polygon.at(i).y(), LineToElement };
        d_func()->elements << elm;
    }
}


Generated by  Doxygen 1.6.0   Back to index