[Development] Forcing clipping rectangle updates for "special" geometries

Loïc Molinari loic.molinari at canonical.com
Thu Aug 8 19:59:18 CEST 2013


I'm creating a custom QQuickItem that casts a shadow around its
geometry. In order to make it easy to use from the QML side, I made
the shadow independent of the item size so that users can manipulate
the item as if it doesn't have a shadow. It's easy to implement with a
scene graph node that has its geometry defined to render outside of
the item rectangle.

Clipping is the only problem I have with it. By default, the clip
rectangle is the same as the item rectangle which makes the renderer
clip the shadow if the "clip" property is enabled. clipRect() being
virtual I can provide my own clip rectangle, that's good but the
problem is that clipRect() is only called when the item size changes
or when the "clip" property is switched. I haven't found anything for
that in QtDeclarative and thought a solution would be to provide an
updateClipRect() method in QQuickItem that would force clipRect() to
be called by making a dedicated flag dirty. I tested it and it works,
the code is here [1].

Is there a built-in solution for that? In case there's not, do you see
a better technique than the one proposed?

Loïc Molinari

[1] http://paste.ubuntu.com/5963311/

More information about the Development mailing list