Mouse events in Qt



  • 1 down vote favorite
    1

    I have 3 events defined as follows:

    @void mouseMoveEvent(QMouseEvent *eventMove);
    void mousePressEvent(QMouseEvent *eventPress);
    void mouseReleaseEvent(QMouseEvent *releaseEvent);@

    Now, let's say I want to do something when the mouse is clicked and moved until the mouse is released. e.g. Give an output ! until the conditions described upper are true.

    I have tried to set a global variable let's say @bool a @

    and make it @true@

    in
    @mousePressEvent(...)@

    and
    @false@

    in

    @mouseReleaseEvent(...)@

    but when in

    @mouseMoveEvent(...)@

    the

    @a@

    is always @true@, even when button is released.



  • Widgets only receive mouse move events when they have received a press but not yet a release event before, i.e. when the mouse is dragging. This is unless the mouse tracking property (setMouseTracking) is enabled. That's why you always see the variable being true.



  • Any solution for that?



  • Well yes, enable mouse tracking o_O


Log in to reply
 

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