<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qevent.cpp --> <title>QHoverEvent Class | Qt GUI 5.12.6</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QHoverEvent</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.12.6 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#protected-variables">Protected Variables</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QHoverEvent Class</h1> <!-- $$$QHoverEvent-brief --> <p>The <a href="qhoverevent.html">QHoverEvent</a> class contains parameters that describe a mouse event. <a href="#details">More...</a></p> <!-- @@@QHoverEvent --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QHoverEvent></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qinputevent.html">QInputEvent</a></td></tr></table></div><ul> <li><a href="qhoverevent-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#QHoverEvent">QHoverEvent</a></b>(QEvent::Type <i>type</i>, const QPointF &<i>pos</i>, const QPointF &<i>oldPos</i>, Qt::KeyboardModifiers <i>modifiers</i> = Qt::NoModifier)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#oldPos">oldPos</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QPointF &</td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#oldPosF">oldPosF</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#pos">pos</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QPointF &</td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#posF">posF</a></b>() const</td></tr> </table></div> <ul> <li class="fn">2 public functions inherited from <a href="qinputevent.html#public-functions">QInputEvent</a></li> <li class="fn">6 public functions inherited from <a href="../qtcore/qevent.html#public-functions">QEvent</a></li> </ul> <a name="protected-variables"></a> <h2 id="protected-variables">Protected Variables</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> QPointF </td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#op-var">op</a></b></td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPointF </td><td class="memItemRight bottomAlign"><b><a href="qhoverevent.html#p-var">p</a></b></td></tr> </table></div> <h3>Additional Inherited Members</h3> <ul> <li class="fn">1 property inherited from <a href="../qtcore/qevent.html#properties">QEvent</a></li> <li class="fn">1 static public member inherited from <a href="../qtcore/qevent.html#static-public-members">QEvent</a></li> </ul> <a name="details"></a> <!-- $$$QHoverEvent-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qhoverevent.html">QHoverEvent</a> class contains parameters that describe a mouse event.</p> <p>Mouse events occur when a mouse cursor is moved into, out of, or within a widget, and if the widget has the <a href="../qtcore/qt.html#WidgetAttribute-enum">Qt::WA_Hover</a> attribute.</p> <p>The function <a href="qhoverevent.html#pos">pos</a>() gives the current cursor position, while <a href="qhoverevent.html#oldPos">oldPos</a>() gives the old mouse position.</p> <p>There are a few similarities between the events <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverEnter</a> and <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverLeave</a>, and the events <a href="../qtcore/qevent.html#Type-enum">QEvent::Enter</a> and <a href="../qtcore/qevent.html#Type-enum">QEvent::Leave</a>. However, they are slightly different because we do an update() in the event handler of <a href="../qtcore/qevent.html#Type-enum">HoverEnter</a> and <a href="../qtcore/qevent.html#Type-enum">HoverLeave</a>.</p> <p><a href="../qtcore/qevent.html#Type-enum">QEvent::HoverMove</a> is also slightly different from <a href="../qtcore/qevent.html#Type-enum">QEvent::MouseMove</a>. Let us consider a top-level window A containing a child B which in turn contains a child C (all with mouse tracking enabled):</p> <p class="centerAlign"><img src="images/hoverevents.png" alt="" /></p><p>Now, if you move the cursor from the top to the bottom in the middle of A, you will get the following <a href="../qtcore/qevent.html#Type-enum">QEvent::MouseMove</a> events:</p> <ol class="1" type="1"><li>A::MouseMove</li> <li>B::MouseMove</li> <li>C::MouseMove</li> </ol> <p>You will get the same events for <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverMove</a>, 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 <a href="../qtcore/qt.html#WidgetAttribute-enum">Qt::WA_NoMousePropagation</a> attribute.</p> <p>In this case the events will occur in the following way:</p> <ol class="1" type="1"><li>A::HoverMove</li> <li>A::HoverMove, B::HoverMove</li> <li>A::HoverMove, B::HoverMove, C::HoverMove</li> </ol> </div> <!-- @@@QHoverEvent --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QHoverEvent[overload1]$$$QHoverEventQEvent::TypeconstQPointF&constQPointF&Qt::KeyboardModifiers --> <h3 class="fn" id="QHoverEvent"><a name="QHoverEvent"></a>QHoverEvent::<span class="name">QHoverEvent</span>(<span class="type"><a href="../qtcore/qevent.html#Type-enum">QEvent::Type</a></span> <i>type</i>, const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &<i>pos</i>, const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &<i>oldPos</i>, <span class="type"><a href="../qtcore/qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a></span> <i>modifiers</i> = Qt::NoModifier)</h3> <p>Constructs a hover event object.</p> <p>The <i>type</i> parameter must be <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverEnter</a>, <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverLeave</a>, or <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverMove</a>.</p> <p>The <i>pos</i> is the current mouse cursor's position relative to the receiving widget, while <i>oldPos</i> is its previous such position. <i>modifiers</i> hold the state of all keyboard modifiers at the time of the event.</p> <!-- @@@QHoverEvent --> <!-- $$$oldPos[overload1]$$$oldPos --> <h3 class="fn" id="oldPos"><a name="oldPos"></a><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QHoverEvent::<span class="name">oldPos</span>() const</h3> <p>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 <a href="qhoverevent.html#pos">pos</a>().</p> <p>On <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverEnter</a> events, this position will always be <a href="../qtcore/qpoint.html">QPoint</a>(-1, -1).</p> <p><b>See also </b><a href="qhoverevent.html#pos">pos</a>().</p> <!-- @@@oldPos --> <!-- $$$oldPosF[overload1]$$$oldPosF --> <h3 class="fn" id="oldPosF"><a name="oldPosF"></a>const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &QHoverEvent::<span class="name">oldPosF</span>() const</h3> <p>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 <a href="qhoverevent.html#posF">posF</a>().</p> <p>On <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverEnter</a> events, this position will always be <a href="../qtcore/qpointf.html">QPointF</a>(-1, -1).</p> <p><b>See also </b><a href="qhoverevent.html#posF">posF</a>().</p> <!-- @@@oldPosF --> <!-- $$$pos[overload1]$$$pos --> <h3 class="fn" id="pos"><a name="pos"></a><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QHoverEvent::<span class="name">pos</span>() const</h3> <p>Returns the position of the mouse cursor, relative to the widget that received the event.</p> <p>On <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverLeave</a> events, this position will always be <a href="../qtcore/qpoint.html">QPoint</a>(-1, -1).</p> <p><b>See also </b><a href="qhoverevent.html#oldPos">oldPos</a>().</p> <!-- @@@pos --> <!-- $$$posF[overload1]$$$posF --> <h3 class="fn" id="posF"><a name="posF"></a>const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &QHoverEvent::<span class="name">posF</span>() const</h3> <p>Returns the position of the mouse cursor, relative to the widget that received the event.</p> <p>On <a href="../qtcore/qevent.html#Type-enum">QEvent::HoverLeave</a> events, this position will always be <a href="../qtcore/qpointf.html">QPointF</a>(-1, -1).</p> <p><b>See also </b><a href="qhoverevent.html#oldPosF">oldPosF</a>().</p> <!-- @@@posF --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> 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. </p> </div> </body> </html>