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

void QPainter::fillPath ( const QPainterPath path,
const QBrush brush 
) [inherited]

Fills the given path using the given brush. The outline is not drawn.

Alternatively, you can specify a QColor instead of a QBrush; the QBrush constructor (taking a QColor argument) will automatically create a solid pattern brush.

See also:
drawPath()

Definition at line 3122 of file qpainter.cpp.

References QGradient::coordinateMode(), QString::data(), QPainter::drawPath(), QPainterPath::elementAt(), QPainterPath::elementCount(), QPainterPath::fillRule(), QBrush::gradient(), QPainter::setBrush(), QPainter::setPen(), QPainterPath::Element::type, QPainterPath::Element::x, and QPainterPath::Element::y.

Referenced by QCDEStyle::drawControl(), NorwegianWoodStyle::drawPrimitive(), RenderArea::drawShape(), QPaintEngine::drawTextItem(), and QGraphicsWidget::paintWindowFrame().

{
    Q_D(QPainter);

    if (!d->engine) {
        qWarning("QPainter::fillPath: Painter not active");
        return;
    }

    if (d->extended) {
        const QGradient *g = brush.gradient();
        if (g && g->coordinateMode() == QGradient::LogicalMode) {
            QVarLengthArray<QPainterPath::ElementType> types(path.elementCount());
            QVarLengthArray<qreal> pts(path.elementCount() * 2);

            uint flags = 0;

            int ptsPos = 0;
            for (int i=0; i<path.elementCount(); ++i) {
                const QPainterPath::Element &e = path.elementAt(i);
                types[i] = e.type;
                pts[ptsPos++] = e.x;
                pts[ptsPos++] = e.y;
                if (e.type == QPainterPath::CurveToElement)
                    flags |= QVectorPath::CurvedShapeHint;
            }
            if (path.fillRule() == Qt::WindingFill)
                flags |= QVectorPath::WindingFill;
            else
                flags |= QVectorPath::OddEvenFill;

            QVectorPath vp(pts.data(), path.elementCount(), types.data(), flags);
            d->extended->fill(vp, brush);
            return;
        }
    }

    QBrush oldBrush = d->state->brush;
    QPen oldPen = d->state->pen;

    setPen(Qt::NoPen);
    setBrush(brush);

    drawPath(path);

    // Reset old state
    setPen(oldPen);
    setBrush(oldBrush);
}


Generated by  Doxygen 1.6.0   Back to index