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

void QPainterPath::addRect ( const QRectF rectangle  ) 

Adds the given rectangle to this path as a closed subpath.

The rectangle is added as a clockwise set of lines. The painter path's current position after the rectangle has been added is at the top-left corner of the rectangle.

100% qpainterpath-addrectangle.png doc/src/snippets/code/src_gui_painting_qpainterpath.cpp 3

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

Definition at line 951 of file qpainterpath.cpp.

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

Referenced by addRect(), addRegion(), addRoundedRect(), addRoundRect(), addText(), QTextLayout::draw(), QTextLine::draw(), QCDEStyle::drawControl(), QRasterPaintEngine::drawImage(), QPaintEngine::drawRects(), QPainter::drawRects(), QRasterPaintEngine::drawTiledPixmap(), QGraphicsView::items(), QGraphicsScene::items(), QTransform::mapRect(), RenderArea::paintEvent(), QGraphicsView::paintEvent(), QGraphicsWidget::paintWindowFrame(), QPainter::setClipRect(), Window::setupShapes(), Mouse::shape(), QGraphicsItem::shape(), QGraphicsWidget::shape(), and SortingBox::SortingBox().

{
#ifndef QT_NO_DEBUG
    if (qt_is_nan(r.x()) || qt_is_nan(r.y()) || qt_is_nan(r.width()) || qt_is_nan(r.height()))
        qWarning("QPainterPath::addRect: Adding rect where a parameter is NaN, results are undefined");
#endif
    if (r.isNull())
        return;

    ensureData();
    detach();

    d_func()->elements.reserve(d_func()->elements.size() + 5);
    moveTo(r.x(), r.y());

    Element l1 = { r.x() + r.width(), r.y(), LineToElement };
    Element l2 = { r.x() + r.width(), r.y() + r.height(), LineToElement };
    Element l3 = { r.x(), r.y() + r.height(), LineToElement };
    Element l4 = { r.x(), r.y(), LineToElement };

    d_func()->elements << l1 << l2 << l3 << l4;
    d_func()->require_moveTo = true;
}


Generated by  Doxygen 1.6.0   Back to index