How QGraphicsItem::HoverLeaveEvent work?
-
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
-
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
@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? -
@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#dragEnterEventAnd 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
-
@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#dragEnterEventAnd 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
@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. -
@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.@JonB I realized some tests and you two are right
So, the documentation is wrong/ bad written? -
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.