Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Mouse events in Qt

Mouse events in Qt

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike_newbye
    wrote on last edited by
    #1

    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.

    Kind regards,
    Mikael

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mike_newbye
        wrote on last edited by
        #3

        Any solution for that?

        Kind regards,
        Mikael

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on last edited by
          #4

          Well yes, enable mouse tracking o_O

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved