QHoverEventclass 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
WA_Hover属性。函数
pos()gives the current cursor position, whileoldPos()gives the old mouse position.There are a few similarities between the events
HoverEnterandHoverLeave, and the eventsEnterandLeave. However, they are slightly different because we do an update() in the event handler ofHoverEnterandHoverLeave.
HoverMoveis also slightly different fromMouseMove. 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
MouseMoveevents:
A::MouseMove
B::MouseMove
C::MouseMove
You will get the same events for
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 theWA_NoMousePropagation属性。In this case the events will occur in the following way:
A::HoverMove
A::HoverMove, B::HoverMove
A::HoverMove, B::HoverMove, C::HoverMove
QHoverEvent
(
type
,
pos
,
oldPos
[
,
modifiers=Qt.NoModifier
]
)
¶
- param type
Type- param modifiers
KeyboardModifiers- param pos
QPointF- param oldPos
QPointF
Constructs a hover event object.
type
参数必须是
HoverEnter
,
HoverLeave
,或
HoverMove
.
pos
is the current mouse cursor’s position relative to the receiving widget, while
oldPos
is its previous such position.
modifiers
hold the state of all keyboard modifiers at the time of the event.
PySide2.QtGui.QHoverEvent.
oldPos
(
)
¶
QPoint
Returns the previous position of the mouse cursor, relative to the widget that received the event. If there is no previous position, will return the same position as
pos()
.
On
HoverEnter
events, this position will always be
QPoint
(-1, -1).
另请参阅
PySide2.QtGui.QHoverEvent.
oldPosF
(
)
¶
QPointF
Returns the previous position of the mouse cursor, relative to the widget that received the event. If there is no previous position, will return the same position as
posF()
.
On
HoverEnter
events, this position will always be
QPointF
(-1, -1).
另请参阅