Capture mouse cruising events (buttons not pressed)

  • I have a

    @ZoomPan_GrView::ZoomPan_GrView(QWidget* parent) : QGraphicsView(parent) { //my subclassed QGraphicsView

    where I can zoom and pan my graphicsview through mouse event handlers:

    @virtual void mousePressEvent(QMouseEvent* event);
    virtual void mouseReleaseEvent(QMouseEvent* event);
    virtual void mouseMoveEvent(QMouseEvent* event);
    virtual void wheelEvent(QWheelEvent* event);
    virtual void resizeEvent(QResizeEvent* event);
    but I want to display the mouse's scene coordinates when mouse simply cruising over the graphicsview.
    All the above events depends on mousebutton press.

    I tried MouseGrabArea and grabMouse() etc. but all I produced were various and impressive crashes:))
    How to grab mouse coordinates when just moving over the graphicsview?

  • Did you enable mouse tracking on the viewport?

  • Thank you, Peppe, this was the problem.
    If I


    than got the

    mouseMoveEvent(QMouseEvent* event)


Log in to reply

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