[Qt-qml] ShaderEffectItem and parent widgets

18 views
Skip to first unread message

Bart Kelsey

unread,
Feb 3, 2012, 3:46:51 PM2/3/12
to qt-...@trolltech.com
Greets!

I'd like to use ShaderEffectItem on a QML widget to have that widget affect the appearance of everything underneath it.  For instance, it would be nice to be able to use a shader to blur and desaturate the area underneath a semi-transparent widget.  This is proving difficult, though, as there's no obvious way for me to access anything on the screen below the widget in question.  The documentation says:

It is possible to define one or more ShaderEffectItems to be a ShaderEffectSource for other ShaderEffectItems, but ShaderEffectItem should never be declared as a child element of its source item(s) because it would cause circular loop in the painting.

Any idea if there's a way to hack around this?  Having a widget that can affect the pixels underneath it (with more than just alpha blending) would allow for some pretty neat effects.

Thanks!

Bart


--
--

Adriano Rezende

unread,
Feb 4, 2012, 8:19:04 AM2/4/12
to Bart Kelsey, qt-...@trolltech.com
 
I don't know much about the implementation of the ShaderEffectItem, but I would assume that it doesn't create a deep cache image of the item. One way to achieve what you want is to create an extended C++ component that uses internally a QGraphicsEffect in order to take a snapshot of the item and its children. You can expose this Snapshot component to qml and apply the effect on this element instead. Notice that this deep cache operation is an expensive one, so the effect should not be active all the time for performance reasons.

Br,
Adriano
Reply all
Reply to author
Forward
0 new messages