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. How QGraphicsItem::HoverLeaveEvent work?

How QGraphicsItem::HoverLeaveEvent work?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 727 Views 1 Watching
  • 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.
  • L Offline
    L Offline
    leonardoMB
    wrote on last edited by leonardoMB
    #1

    To begin with, what is the difference between the DragEnter and HoverEnter? And between DragLeave and HoverLeave? I'm with a problem that is not making sense to me, I reimplemented the HoverLeaveEvent and HoverEnterEvent for my Button class. I use them to display some tooltips and it works fine. The problem is when I press the button and move it while pressed, I would expected that as soon as I leave the button area I would receive a HoverLeaveEvent, but it seems that don't work like that. What is this behavior? Thanks in advance

    JonBJ 1 Reply Last reply
    0
    • L leonardoMB

      To begin with, what is the difference between the DragEnter and HoverEnter? And between DragLeave and HoverLeave? I'm with a problem that is not making sense to me, I reimplemented the HoverLeaveEvent and HoverEnterEvent for my Button class. I use them to display some tooltips and it works fine. The problem is when I press the button and move it while pressed, I would expected that as soon as I leave the button area I would receive a HoverLeaveEvent, but it seems that don't work like that. What is this behavior? Thanks in advance

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @leonardoMB
      My expectation would be that "drag" stuff happens when dragging, which means with the mouse button pressed, while "hover" stuff happens when "hovering", which means with the mouse button not pressed?

      1 Reply Last reply
      3
      • PedroP Offline
        PedroP Offline
        Pedro
        wrote on last edited by
        #3

        Hover: when your cursor just flies over an object, not clicking on it.
        Drag: when you actually click on it and drag it, moving it around.

        I think your question has more to do with the English language than with coding, am I correct?

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leonardoMB
          wrote on last edited by leonardoMB
          #4

          @Pedro @JonB
          Its a English language problem in some extent, I agree with your deffinitions Pedro, but in the Qt documentation it says : "This event handler, for event event, can be reimplemented to receive drag enter events for this item. Drag enter events are generated as the cursor enters the item's area."
          https://doc.qt.io/qt-5/qgraphicsitem.html#dragEnterEvent

          And for me, the part that is in bold is the equivalent of Hover.

          I thought that Hover would occurs when my mouse is in the item, so if I put my mouse on the button without click, isHover = true, and if I click, I would expect that isHover would continue true, but with an additional Drag event being called. When I move the mouse I would expect a DragMove and if the mouse is not in the item anymore I would expect a HoverLeave event, but this don't occur.

          Probably I'm not expressing myself so well in english too. I ask for patience if that's the case

          JonBJ 1 Reply Last reply
          0
          • L leonardoMB

            @Pedro @JonB
            Its a English language problem in some extent, I agree with your deffinitions Pedro, but in the Qt documentation it says : "This event handler, for event event, can be reimplemented to receive drag enter events for this item. Drag enter events are generated as the cursor enters the item's area."
            https://doc.qt.io/qt-5/qgraphicsitem.html#dragEnterEvent

            And for me, the part that is in bold is the equivalent of Hover.

            I thought that Hover would occurs when my mouse is in the item, so if I put my mouse on the button without click, isHover = true, and if I click, I would expect that isHover would continue true, but with an additional Drag event being called. When I move the mouse I would expect a DragMove and if the mouse is not in the item anymore I would expect a HoverLeave event, but this don't occur.

            Probably I'm not expressing myself so well in english too. I ask for patience if that's the case

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #5

            @leonardoMB
            I suggested that "drag" events always require the mouse to be pressed and "hover" events always require the mouse not to be pressed. Maybe that is indeed your finding.

            L 1 Reply Last reply
            2
            • JonBJ JonB

              @leonardoMB
              I suggested that "drag" events always require the mouse to be pressed and "hover" events always require the mouse not to be pressed. Maybe that is indeed your finding.

              L Offline
              L Offline
              leonardoMB
              wrote on last edited by
              #6

              @JonB I realized some tests and you two are right
              So, the documentation is wrong/ bad written?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi,

                No, the document is correct. You are excluding the fact that your are actually "moving something across the widget" when the drag operation is in progress in your analysis. These are two different use cases.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1

                • Login

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