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

void QWidget::render ( QPainter painter,
const QPoint targetOffset = QPoint(),
const QRegion sourceRegion = QRegion(),
RenderFlags  renderFlags = RenderFlags(DrawWindowBackground | DrawChildren) 
) [inherited]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Renders the widget into the painter's QPainter::device().

Transformations and settings applied to the painter will be used when rendering.

Note:
The painter must be active. On Mac OS X the widget will be rendered into a QPixmap and then drawn by the painter.
See also:
QPainter::device()

Definition at line 4402 of file qwidget.cpp.

References QRegion::boundingRect(), QPainter::device(), QPaintEngineState::dirtyFlags, QPainter::drawPixmap(), QPixmap::fill(), QPainter::isActive(), QRegion::isEmpty(), QSize::isNull(), QPainter::opacity(), QPaintEngine::paintDevice(), QPainter::paintEngine(), QWidget::render(), QPainter::renderHints(), QPainter::setRenderHints(), QRect::size(), QWidget::size, QPaintEngine::state, QPaintEngine::type(), QPaintEngine::updateState(), QWidget::window(), and QPainter::worldMatrixEnabled().

{
    if (!painter) {
        qWarning("QWidget::render: Null pointer to painter");
        return;
    }

    if (!painter->isActive()) {
        qWarning("QWidget::render: Cannot render with an inactive painter");
        return;
    }

    Q_D(QWidget);
    QWidget *topLevel = window();
    const QRegion toBePainted = d->prepareToRender(sourceRegion, renderFlags, topLevel);
    if (toBePainted.isEmpty())
        return;

    QTLWExtra *extra = topLevel->d_func()->topData();
    extra->inRenderWithPainter = true;
    QPainter *oldPainter = extra->sharedPainter;
#ifndef Q_WS_MAC
    extra->sharedPainter = painter;
#endif

    QPaintEngine *engine = painter->paintEngine();
    Q_ASSERT(engine);
    QPaintEnginePrivate *enginePriv = engine->d_func();
    Q_ASSERT(enginePriv);
    QPaintDevice *target = painter->worldMatrixEnabled() ? engine->paintDevice() : painter->device();
    Q_ASSERT(target);

    // Save current system clip.
    const QRegion oldSystemClip = enginePriv->systemClip;
    enginePriv->oldSystemClipPath.addRegion(oldSystemClip);

#ifdef Q_WS_MAC
    Q_UNUSED(target);
    // Render via a pixmap.
    const QRect rect = toBePainted.boundingRect();
    const QSize size = rect.size();
    if (size.isNull()) {
        extra->inRenderWithPainter = false;
        return;
    }

    QPixmap pixmap(size);
    if (!(renderFlags & DrawWindowBackground))
        pixmap.fill(Qt::transparent);
    render(&pixmap, QPoint(), toBePainted, renderFlags);

    const bool restore = !(painter->renderHints() & QPainter::SmoothPixmapTransform);
    painter->setRenderHints(QPainter::SmoothPixmapTransform, true);

    painter->drawPixmap(QRect(targetOffset, size), pixmap);

    if (restore)
        painter->setRenderHints(QPainter::SmoothPixmapTransform, false);
#else
    const qreal oldGlobalOpacity = extra->globalOpacity;
    extra->globalOpacity = painter->opacity();
    render(target, targetOffset, toBePainted, renderFlags);
    extra->globalOpacity = oldGlobalOpacity;
#endif

    // Restore system clip.
    if (engine->type() == QPaintEngine::Raster)
        static_cast<QRasterPaintEnginePrivate *>(enginePriv)->baseClip = enginePriv->oldSystemClipPath;
    enginePriv->systemClip = oldSystemClip;
    enginePriv->oldSystemClipPath = QPainterPath();

    // Update painter state with new clip.
    QPaintEngineState *state = engine->state;
    Q_ASSERT(state);
    state->dirtyFlags |= QPaintEngine::DirtyClipEnabled | QPaintEngine::DirtyClipRegion;
    engine->updateState(*state);

    extra->sharedPainter = oldPainter;
    extra->inRenderWithPainter = false;
}


Generated by  Doxygen 1.6.0   Back to index