Mouse Click/Press event partially working on QGraphicsPixmaxItem.
-
Hello all,
I have plotted a QGraphicsPixmaxItem on which i set a transparent pixmap of circle. I am capturing mouse events like mouse click/press on this item successfully.
I observed the two things:
When i click on perimeter of this circle then only i am getting click event, but when i click inside the circle then i am not getting any click event.
My Question is How can in get click event inside the circle ? -
Hello.
Is your circle solid or contains your item only the outline? What boundingRect are you using? Normally the MouseEvents are triggert, when you perform actions inside the items boundingRect.
If you just need a circle, QGraphicsEllipseItem should do the same for you. -
@IamSumit
see the QGraphicsPixmapItem::setShapeMode()
By default it'sQGraphicsPixmapItem::MaskShape
, which means the transparent areas in the pixmap wont be added to it's shape which is responsible for the clickable area.
You want it to set toQGraphicsPixmapItem::BoundingRectShape
, or reimplementQGraphicsItem::shape()
yourself.