IOS 7 Style Translucency.



  • This has been discussed for QWidgets here http://stackoverflow.com/questions/19883902/obtain-ios7-like-blur-effect-with-qt.

    But I am looking for solutions for GraphicsView Framework.

    I have a scenario with two overlapping QGraphicsWidget (e,g A is on top B) , I want to blur the the part of B which is visible through A.

    The way I understand to do this is to render B to a offscreen buffer, find the area on B which will be occluded by A, blur it and use it as a background fill for A. Seems straightforward. But apparently not.

    Problem 1. Render QGraphicsWidget to a offscreen buffer.

    Calling QGraphicsWidget::pain with a custom painter is in sufficient because it will not render its children. There is no QGraphicsWidget::grab which exists for QWidget::grap /QPixmap::grabwidget (deprecated). The only real way seems to go out and do a scene.render on a custom painter (with A not visible) every time B needs a repaint. Well we have to render twice now, also with ugly code.

    There has to be a simple solution right to get this buffer right?

    I created a custom pass through QGraphicsEffect ( applied to B ) which does nothing but emits out the sourceImage.

    something to the effect of
    @
    const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
    emit widgetpixmap(pixmap,offset);
    QTransform restore = painter->transform();
    painter->setWorldTransform(QTransform());
    painter->drawPixmap(offset, pixmap);
    painter->setWorldTransform(restore);
    @
    in the draw function.

    I connect this signal with a slot on widget A which updates a cached pixmap. with this I get a legitimate pixmap in device coordinates for widget B in widget A. So far so good.

    Problem 2 . Now this where I am stuck - I am unable to convert this pixmap for use in coordinate system for Widget A. How do I figure out which part of this pixmap needs to be blurred?

    I could also emit the the current transform from this custom effect but how do I use that information in Widget A.

    ps: Is there a simpler way to do this?



  • Also, The best and easiest solution would have been a blur composition mode for QPainter. Feature request -> Allow custom composition modes to be passed in.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.