QGraphicsView::mouseReleaseEvent ensures that I can't select QGraphicsItems anymore

  • Hey,
    In a nutshell: When I implement the mouseReleaseEvent in my QGraphicsView derived class, this happens:
    When I click on an item (QGraphicsItem that I added to the scene), the mousePressEvent of this item gets triggered. But when I click on another item, the old item (this first item I clicked on) is triggered again and not the new one.
    When I delete the mouseReleaseEvent function in the QGraphicsView derived class (so I do not override it anymore), everything works.
    Why is this and how can I fix this?

    Thanks for answers!

    Never forget to call

    QGraphicsView::mousePressEvent(event); /
    QGraphicsView::mouseReleaseEvent(event); /

    at the end of every mouseEvent you overrode in your QGraphicsView derived class (in the mouseMoveEvent use QGraphicsView::mouseMoveEvent(event) and so on).
    Otherwise really strange things can happen.
    Also if you even did not use some of these in your QGraphicsItem derived class, call it in every event.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.