
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQHoverEvent class contains parameters that describe a mouse event.More...
| Header: | #include <QHoverEvent> |
| Inherits: | QEvent |
| QHoverEvent(Type type, const QPoint & pos, const QPoint & oldPos) | |
| const QPoint & | oldPos() const |
| const QPoint & | pos() const |
TheQHoverEvent class contains parameters that describe a mouse event.
Mouse events occur when a mouse cursor is moved into, out of, or within a widget, and if the widget has theQt::WA_Hover attribute.
The functionpos() gives the current cursor position, whileoldPos() gives the old mouse position.
There are a few similarities between the eventsQEvent::HoverEnter andQEvent::HoverLeave, and the eventsQEvent::Enter andQEvent::Leave. However, they are slightly different because we do an update() in the event handler ofHoverEnter andHoverLeave.
QEvent::HoverMove is also slightly different fromQEvent::MouseMove. Let us consider a top-level window A containing a child B which in turn contains a child C (all with mouse tracking enabled):

Now, if you move the cursor from the top to the bottom in the middle of A, you will get the followingQEvent::MouseMove events:
You will get the same events forQEvent::HoverMove, except that the event always propagates to the top-level regardless whether the event is accepted or not. It will only stop propagating with theQt::WA_NoMousePropagation attribute.
In this case the events will occur in the following way:
Constructs a hover event object.
Thetype parameter must beQEvent::HoverEnter,QEvent::HoverLeave, orQEvent::HoverMove.
Thepos is the current mouse cursor's position relative to the receiving widget, whileoldPos is the previous mouse cursor's position relative to the receiving widget.
Returns the previous position of the mouse cursor, relative to the widget that received the event. If there is no previous position, oldPos() will return the same position aspos().
OnQEvent::HoverEnter events, this position will always beQPoint(-1, -1).
See alsopos().
Returns the position of the mouse cursor, relative to the widget that received the event.
OnQEvent::HoverLeave events, this position will always beQPoint(-1, -1).
See alsooldPos().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.