Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. IOS 7 Style Translucency.
Qt 6.11 is out! See what's new in the release blog

IOS 7 Style Translucency.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ankitkk
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ankitkk
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved