Qt 4.8
|
The QHoverEvent class contains parameters that describe a mouse event. More...
#include <qevent.h>
Public Functions | |
const QPoint & | oldPos () const |
Returns the previous position of the mouse cursor, relative to the widget that received the event. More... | |
const QPoint & | pos () const |
Returns the position of the mouse cursor, relative to the widget that received the event. More... | |
QHoverEvent (Type type, const QPoint &pos, const QPoint &oldPos) | |
Constructs a hover event object. More... | |
~QHoverEvent () | |
Public Functions inherited from QEvent | |
void | accept () |
Sets the accept flag of the event object, the equivalent of calling setAccepted(true). More... | |
void | ignore () |
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false). More... | |
bool | isAccepted () const |
QEvent (Type type) | |
Contructs an event object of type type. More... | |
void | setAccepted (bool accepted) |
bool | spontaneous () const |
Returns true if the event originated outside the application (a system event); otherwise returns false. More... | |
Type | type () const |
Returns the event type. More... | |
virtual | ~QEvent () |
Destroys the event. More... | |
Protected Variables | |
QPoint | op |
QPoint | p |
Protected Variables inherited from QEvent | |
QEventPrivate * | d |
ushort | t |
The QHoverEvent 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 the Qt::WA_Hover attribute.
The function pos() gives the current cursor position, while oldPos() gives the old mouse position.
There are a few similarities between the events QEvent::HoverEnter and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave. However, they are slightly different because we do an update() in the event handler of HoverEnter and HoverLeave.
QEvent::HoverMove is also slightly different from QEvent::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 following QEvent::MouseMove events:
You will get the same events for QEvent::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 the Qt::WA_NoMousePropagation attribute.
In this case the events will occur in the following way:
Constructs a hover event object.
The type parameter must be QEvent::HoverEnter, QEvent::HoverLeave, or QEvent::HoverMove.
The pos is the current mouse cursor's position relative to the receiving widget, while oldPos is the previous mouse cursor's position relative to the receiving widget.
Definition at line 531 of file qevent.cpp.
QHoverEvent::~QHoverEvent | ( | ) |
Definition at line 539 of file qevent.cpp.
|
inline |
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 as pos().
On QEvent::HoverEnter events, this position will always be QPoint(-1, -1).
Definition at line 132 of file qevent.h.
Referenced by QTabBar::event().
|
inline |
Returns the position of the mouse cursor, relative to the widget that received the event.
On QEvent::HoverLeave events, this position will always be QPoint(-1, -1).
Definition at line 131 of file qevent.h.
Referenced by QToolBar::event(), QTabBar::event(), QHeaderView::event(), and QTreeView::viewportEvent().