Qt-interest Archive, February 2008
Mask part of QGraphicsItem
Message 1 in thread
Hello! I think if you use photoshop or gimp you know what "mask layer" is.
It is a way to hide custom parts of the real layer.
So what I need is to completely hide part of QGraphicsItem. For example
show only half of QGraphicsItem. And invisible half must not only be
invisible, but also pass all events etc. I have full access to QGraphicsItem
class I need to hide, but I can't reconstruct it, only change the ways it
painted or acts on events. So I see how to pass events throw it: store
hidden QRectPath and check if event in it or not. But how to implement
virtual void paint ( QPainter*, const QStyleOptionGraphicsItem*, QWidget* )
function to skip invisible QRectPath?
Message 2 in thread
On mandag den 11. Februar 2008, Alexei Sergeev wrote:
> Hello! I think if you use photoshop or gimp you know what "mask layer" is.
> It is a way to hide custom parts of the real layer.
> So what I need is to completely hide part of QGraphicsItem. For example
> show only half of QGraphicsItem. And invisible half must not only be
> invisible, but also pass all events etc. I have full access to
> QGraphicsItem class I need to hide, but I can't reconstruct it, only change
> the ways it painted or acts on events. So I see how to pass events throw
> it: store hidden QRectPath and check if event in it or not. But how to
> implement virtual void paint ( QPainter*, const QStyleOptionGraphicsItem*,
> QWidget* ) function to skip invisible QRectPath?
You might do this by setting a clipping region on the painter. So your
overridden method would look something like this:
paint(QPainter* painter, ...) {
painter->setClipRegion(...);
BaseClass:paint(painter, ...);
}
This would be my first attempt at solving this problem.
Bo.
--
[ signature omitted ]