1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qevent.cpp -->
<title>Qt 4.8: QWheelEvent Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtgui.html">QtGui</a></li>
<li>QWheelEvent</li>
</ul>
</div>
</div>
<div class="content mainContent">
<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="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QWheelEvent Class Reference</h1>
<!-- $$$QWheelEvent-brief -->
<p>The QWheelEvent class contains parameters that describe a wheel event. <a href="#details">More...</a></p>
<!-- @@@QWheelEvent -->
<pre class="cpp"> <span class="preprocessor">#include <QWheelEvent></span></pre><p><b>Inherits: </b><a href="qinputevent.html">QInputEvent</a>.</p>
<ul>
<li><a href="qwheelevent-members.html">List of all members, including inherited members</a></li>
<li><a href="qwheelevent-qt3.html">Qt 3 support members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#QWheelEvent">QWheelEvent</a></b> ( const QPoint & <i>pos</i>, int <i>delta</i>, Qt::MouseButtons <i>buttons</i>, Qt::KeyboardModifiers <i>modifiers</i>, Qt::Orientation <i>orient</i> = Qt::Vertical )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#QWheelEvent-2">QWheelEvent</a></b> ( const QPoint & <i>pos</i>, const QPoint & <i>globalPos</i>, int <i>delta</i>, Qt::MouseButtons <i>buttons</i>, Qt::KeyboardModifiers <i>modifiers</i>, Qt::Orientation <i>orient</i> = Qt::Vertical )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::MouseButtons </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#buttons">buttons</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#delta">delta</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QPoint & </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#globalPos">globalPos</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#globalX">globalX</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#globalY">globalY</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::Orientation </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#orientation">orientation</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QPoint & </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#pos">pos</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#x">x</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qwheelevent.html#y">y</a></b> () const</td></tr>
</table>
<ul>
<li class="fn">1 public function inherited from <a href="qinputevent.html#public-functions">QInputEvent</a></li>
<li class="fn">6 public functions inherited from <a href="qevent.html#public-functions">QEvent</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 property inherited from <a href="qevent.html#properties">QEvent</a></li>
<li class="fn">1 static public member inherited from <a href="qevent.html#static-public-members">QEvent</a></li>
</ul>
<a name="details"></a>
<!-- $$$QWheelEvent-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QWheelEvent class contains parameters that describe a wheel event.</p>
<p>Wheel events are sent to the widget under the mouse cursor, but if that widget does not handle the event they are sent to the focus widget. The rotation distance is provided by <a href="qwheelevent.html#delta">delta</a>(). The functions <a href="qwheelevent.html#pos">pos</a>() and <a href="qwheelevent.html#globalPos">globalPos</a>() return the mouse cursor's location at the time of the event.</p>
<p>A wheel event contains a special accept flag that indicates whether the receiver wants the event. You should call <a href="qevent.html#ignore">ignore</a>() if you do not handle the wheel event; this ensures that it will be sent to the parent widget.</p>
<p>The <a href="qwidget.html#enabled-prop">QWidget::setEnabled</a>() function can be used to enable or disable mouse and keyboard events for a widget.</p>
<p>The event handler <a href="qwidget.html#wheelEvent">QWidget::wheelEvent</a>() receives wheel events.</p>
</div>
<p><b>See also </b><a href="qmouseevent.html">QMouseEvent</a> and <a href="qwidget.html#grabMouse">QWidget::grabMouse</a>().</p>
<!-- @@@QWheelEvent -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QWheelEvent[overload1]$$$QWheelEventconstQPoint&intQt::MouseButtonsQt::KeyboardModifiersQt::Orientation -->
<h3 class="fn"><a name="QWheelEvent"></a>QWheelEvent::<span class="name">QWheelEvent</span> ( const <span class="type"><a href="qpoint.html">QPoint</a></span> & <i>pos</i>, <span class="type">int</span> <i>delta</i>, <span class="type"><a href="qt.html#MouseButton-enum">Qt::MouseButtons</a></span> <i>buttons</i>, <span class="type"><a href="qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a></span> <i>modifiers</i>, <span class="type"><a href="qt.html#Orientation-enum">Qt::Orientation</a></span> <i>orient</i> = Qt::Vertical )</h3>
<p>Constructs a wheel event object.</p>
<p>The position, <i>pos</i>, is the location of the mouse cursor within the widget. The <a href="qwheelevent.html#globalPos">globalPos</a>() is initialized to <a href="qcursor.html#pos">QCursor::pos</a>() which is usually, but not always, correct. Use the other constructor if you need to specify the global position explicitly.</p>
<p>The <i>buttons</i> describe the state of the mouse buttons at the time of the event, <i>delta</i> contains the rotation distance, <i>modifiers</i> holds the keyboard modifier flags at the time of the event, and <i>orient</i> holds the wheel's orientation.</p>
<p><b>See also </b><a href="qwheelevent.html#pos">pos</a>(), <a href="qwheelevent.html#delta">delta</a>(), and <a href="qwheelevent-qt3.html#state" class="compat">state</a>().</p>
<!-- @@@QWheelEvent -->
<!-- $$$QWheelEvent$$$QWheelEventconstQPoint&constQPoint&intQt::MouseButtonsQt::KeyboardModifiersQt::Orientation -->
<h3 class="fn"><a name="QWheelEvent-2"></a>QWheelEvent::<span class="name">QWheelEvent</span> ( const <span class="type"><a href="qpoint.html">QPoint</a></span> & <i>pos</i>, const <span class="type"><a href="qpoint.html">QPoint</a></span> & <i>globalPos</i>, <span class="type">int</span> <i>delta</i>, <span class="type"><a href="qt.html#MouseButton-enum">Qt::MouseButtons</a></span> <i>buttons</i>, <span class="type"><a href="qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a></span> <i>modifiers</i>, <span class="type"><a href="qt.html#Orientation-enum">Qt::Orientation</a></span> <i>orient</i> = Qt::Vertical )</h3>
<p>Constructs a wheel event object.</p>
<p>The <i>pos</i> provides the location of the mouse cursor within the widget. The position in global coordinates is specified by <i>globalPos</i>. <i>delta</i> contains the rotation distance, <i>modifiers</i> holds the keyboard modifier flags at the time of the event, and <i>orient</i> holds the wheel's orientation.</p>
<p><b>See also </b><a href="qwheelevent.html#pos">pos</a>(), <a href="qwheelevent.html#globalPos">globalPos</a>(), <a href="qwheelevent.html#delta">delta</a>(), and <a href="qwheelevent-qt3.html#state" class="compat">state</a>().</p>
<!-- @@@QWheelEvent -->
<!-- $$$buttons[overload1]$$$buttons -->
<h3 class="fn"><a name="buttons"></a><span class="type"><a href="qt.html#MouseButton-enum">Qt::MouseButtons</a></span> QWheelEvent::<span class="name">buttons</span> () const</h3>
<p>Returns the mouse state when the event occurred.</p>
<!-- @@@buttons -->
<!-- $$$delta[overload1]$$$delta -->
<h3 class="fn"><a name="delta"></a><span class="type">int</span> QWheelEvent::<span class="name">delta</span> () const</h3>
<p>Returns the distance that the wheel is rotated, in eighths of a degree. A positive value indicates that the wheel was rotated forwards away from the user; a negative value indicates that the wheel was rotated backwards toward the user.</p>
<p>Most mouse types work in steps of 15 degrees, in which case the delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.</p>
<p>However, some mice have finer-resolution wheels and send delta values that are less than 120 units (less than 15 degrees). To support this possibility, you can either cumulatively add the delta values from events until the value of 120 is reached, then scroll the widget, or you can partially scroll the widget in response to each wheel event.</p>
<p>Example:</p>
<pre class="cpp"> <span class="type">void</span> MyWidget<span class="operator">::</span>wheelEvent(<span class="type"><a href="qwheelevent.html">QWheelEvent</a></span> <span class="operator">*</span>event)
{
<span class="type">int</span> numDegrees <span class="operator">=</span> event<span class="operator">-</span><span class="operator">></span>delta() <span class="operator">/</span> <span class="number">8</span>;
<span class="type">int</span> numSteps <span class="operator">=</span> numDegrees <span class="operator">/</span> <span class="number">15</span>;
<span class="keyword">if</span> (event<span class="operator">-</span><span class="operator">></span>orientation() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">::</span>Horizontal) {
scrollHorizontally(numSteps);
} <span class="keyword">else</span> {
scrollVertically(numSteps);
}
event<span class="operator">-</span><span class="operator">></span>accept();
}</pre>
<!-- @@@delta -->
<!-- $$$globalPos[overload1]$$$globalPos -->
<h3 class="fn"><a name="globalPos"></a>const <span class="type"><a href="qpoint.html">QPoint</a></span> & QWheelEvent::<span class="name">globalPos</span> () const</h3>
<p>Returns the global position of the mouse pointer <i>at the time of the event</i>. This is important on asynchronous window systems such as X11; whenever you move your widgets around in response to mouse events, globalPos() can differ a lot from the current cursor position returned by <a href="qcursor.html#pos">QCursor::pos</a>().</p>
<p><b>See also </b><a href="qwheelevent.html#globalX">globalX</a>() and <a href="qwheelevent.html#globalY">globalY</a>().</p>
<!-- @@@globalPos -->
<!-- $$$globalX[overload1]$$$globalX -->
<h3 class="fn"><a name="globalX"></a><span class="type">int</span> QWheelEvent::<span class="name">globalX</span> () const</h3>
<p>Returns the global x position of the mouse cursor at the time of the event.</p>
<p><b>See also </b><a href="qwheelevent.html#globalY">globalY</a>() and <a href="qwheelevent.html#globalPos">globalPos</a>().</p>
<!-- @@@globalX -->
<!-- $$$globalY[overload1]$$$globalY -->
<h3 class="fn"><a name="globalY"></a><span class="type">int</span> QWheelEvent::<span class="name">globalY</span> () const</h3>
<p>Returns the global y position of the mouse cursor at the time of the event.</p>
<p><b>See also </b><a href="qwheelevent.html#globalX">globalX</a>() and <a href="qwheelevent.html#globalPos">globalPos</a>().</p>
<!-- @@@globalY -->
<!-- $$$orientation[overload1]$$$orientation -->
<h3 class="fn"><a name="orientation"></a><span class="type"><a href="qt.html#Orientation-enum">Qt::Orientation</a></span> QWheelEvent::<span class="name">orientation</span> () const</h3>
<p>Returns the wheel's orientation.</p>
<!-- @@@orientation -->
<!-- $$$pos[overload1]$$$pos -->
<h3 class="fn"><a name="pos"></a>const <span class="type"><a href="qpoint.html">QPoint</a></span> & QWheelEvent::<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>If you move your widgets around in response to mouse events, use <a href="qwheelevent.html#globalPos">globalPos</a>() instead of this function.</p>
<p><b>See also </b><a href="qwheelevent.html#x">x</a>(), <a href="qwheelevent.html#y">y</a>(), and <a href="qwheelevent.html#globalPos">globalPos</a>().</p>
<!-- @@@pos -->
<!-- $$$x[overload1]$$$x -->
<h3 class="fn"><a name="x"></a><span class="type">int</span> QWheelEvent::<span class="name">x</span> () const</h3>
<p>Returns the x position of the mouse cursor, relative to the widget that received the event.</p>
<p><b>See also </b><a href="qwheelevent.html#y">y</a>() and <a href="qwheelevent.html#pos">pos</a>().</p>
<!-- @@@x -->
<!-- $$$y[overload1]$$$y -->
<h3 class="fn"><a name="y"></a><span class="type">int</span> QWheelEvent::<span class="name">y</span> () const</h3>
<p>Returns the y position of the mouse cursor, relative to the widget that received the event.</p>
<p><b>See also </b><a href="qwheelevent.html#x">x</a>() and <a href="qwheelevent.html#pos">pos</a>().</p>
<!-- @@@y -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
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.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|