Important: Please read the Qt Code of Conduct -

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.

  • Moderators

    see the QGraphicsPixmapItem::setShapeMode()
    By default it's QGraphicsPixmapItem::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 to QGraphicsPixmapItem::BoundingRectShape, or reimplement QGraphicsItem::shape() yourself.

Log in to reply