QHoverEvent 类包含鼠标事件的描述参数。 更多...
头: | #include <QHoverEvent> |
CMake: |
find_package(Qt6 COMPONENTS Gui REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QSinglePointEvent |
QHoverEvent (QEvent::Type type , const QPointF & pos , const QPointF & oldPos , Qt::KeyboardModifiers modifiers = Qt::NoModifier, const QPointingDevice * device = QPointingDevice::primaryPointingDevice()) | |
QPoint | oldPos () const |
QPointF | oldPosF () const |
出现鼠标事件,当鼠标光标移入/移出 Widget,或在 Widget 内移动时,且若小部件拥有 Qt::WA_Hover 属性。
The function pos() gives the current cursor position, while oldPos () 给出旧鼠标位置。
有一些相似介于事件 QEvent::HoverEnter and QEvent::HoverLeave ,和事件 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 也稍微不同于 QEvent::MouseMove 。让我们考虑顶层 A 窗口,其包含子级 B,而 B 又包含子级 C (都有启用鼠标跟踪):
现在,若将光标从 A 中间的顶部移到底部,将获得下列 QEvent::MouseMove 事件:
将获得相同事件 QEvent::HoverMove ,除事件始终会被传播给顶层外,不管事件是否被接受。它才会停止传播采用 Qt::WA_NoMousePropagation 属性。
在此情况下,事件将按下列方式出现:
Constructs a hover event object originating from device .
type 参数必须是 QEvent::HoverEnter , QEvent::HoverLeave ,或 QEvent::HoverMove .
pos 是相对于接收 Widget 的当前鼠标光标位置,而 oldPos 是它的先前这种位置。 modifiers 保持事件发生时所有键盘修饰符的状态。
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 事件,此位置将始终是 QPoint (-1, -1).
另请参阅 pos ().
Returns the previous position of the mouse cursor, relative to the widget that received the event. If there is no previous position, oldPosF() will return the same position as posF().
On QEvent::HoverEnter 事件,此位置将始终是 QPointF (-1, -1).
另请参阅 posF ().