From 543cceb53795a1af8a3515a18025998f24ff4ca0 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Tue, 10 Nov 2009 22:02:21 +0100 Subject: =?UTF-8?q?Documentation:=20Adding=20comments=20to=20QHoverEvent?= =?UTF-8?q?=20class=20Explaining=20the=20difference=20between=20hover=20ev?= =?UTF-8?q?ents=20and=20enter/leave/move=20events=20Task-number:=20QT-1116?= =?UTF-8?q?=20Reviewed-by:=20Bj=C3=B8rn=20Erik=20Nilsen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/src/images/hoverevents.png | Bin 0 -> 3210 bytes src/gui/kernel/qevent.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 doc/src/images/hoverevents.png diff --git a/doc/src/images/hoverevents.png b/doc/src/images/hoverevents.png new file mode 100644 index 0000000000..ccc079bdf1 Binary files /dev/null and b/doc/src/images/hoverevents.png differ diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ff97405ea8..c4a25e18c2 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -399,6 +399,40 @@ QMouseEventEx::~QMouseEventEx() 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): + + \image hoverEvents.png + + 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: + + \list 1 + \o A::MouseMove + \o B::MouseMove + \o C::MouseMove + \endlist + + 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: + + \list 1 + \o A::HoverMove + \o A::HoverMove, B::HoverMove + \o A::HoverMove, B::HoverMove, C::HoverMove + \endlist + */ /*! -- cgit v1.2.3