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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QMouseEvent Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QMouseEvent Class Reference</h1><br clear="all">
<p>
The QMouseEvent class contains parameters that describe a mouse event.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qevent-h.html">qevent.h</a>></code>
<p>
Inherits <a href="qevent.html">QEvent</a>.
<p><a href="qmouseevent-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#6d471e"><b>QMouseEvent</b></a>(Typetype, constQPoint&pos, intbutton, intstate)</div>
<li><div class="fn"><a href="#e49f8c"><b>QMouseEvent</b></a>(Typetype, constQPoint&pos, constQPoint&globalPos, intbutton, intstate)</div>
<li><div class="fn">constQPoint&<a href="#ac6f25"><b>pos</b></a>()const</div>
<li><div class="fn">constQPoint&<a href="#3f4ad0"><b>globalPos</b></a>()const</div>
<li><div class="fn">int<a href="#07ad9e"><b>x</b></a>()const</div>
<li><div class="fn">int<a href="#b63f4c"><b>y</b></a>()const</div>
<li><div class="fn">int<a href="#53ffae"><b>globalX</b></a>()const</div>
<li><div class="fn">int<a href="#48cb99"><b>globalY</b></a>()const</div>
<li><div class="fn">ButtonState<a href="#78482f"><b>button</b></a>()const</div>
<li><div class="fn">ButtonState<a href="#db99dc"><b>state</b></a>()const</div>
<li><div class="fn">ButtonState<a href="#acd7fe"><b>stateAfter</b></a>()const</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QMouseEvent class contains parameters that describe a mouse event.
<p>
Mouse events occur when a mouse button is pressed or released inside a
widget, or when the mouse cursor is moved.
<p>Mouse move events will only occur when some mouse button is pressed
down, unless mouse tracking has been enabled with
<a href="qwidget.html#36406c">QWidget::setMouseTracking</a>().
<p>Qt automatically grabs the mouse when a mouse button is pressed inside a
widget, and the widget will continue to receive mouse events until the
last mouse button is released.
<p>The functions <a href="#ac6f25">pos</a>(), <a href="#07ad9e">x</a>() and <a href="#b63f4c">y</a>() give the cursor position relative
to the widget that receives the mouse event. If you move the widget
as a result of the mouse event, use the global position returned by
<a href="#3f4ad0">globalPos</a>() to avoid a shaking motion.
<p>The QWidget::setEnable() function can be used to enable or disable mouse
and keyboard events for a widget.
<p>The event handlers <a href="qwidget.html#2ecc04">QWidget::mousePressEvent</a>(), <a href="qwidget.html#9aa77f">QWidget::mouseReleaseEvent</a>(),
<a href="qwidget.html#e36586">QWidget::mouseDoubleClickEvent</a>() and <a href="qwidget.html#a51d92">QWidget::mouseMoveEvent</a>() receive
mouse events.
<p>See also <a href="qwidget.html#36406c">QWidget::setMouseTracking</a>(), <a href="qwidget.html#5bdd5f">QWidget::grabMouse</a>() and <a href="qcursor.html#5bce2b">QCursor::pos</a>().
<p>Examples:
<a href="qtimage-qtimage-cpp.html#QMouseEvent">qtimage/qtimage.cpp</a>
<a href="drawlines-connect-cpp.html#QMouseEvent">drawlines/connect.cpp</a>
<a href="popup-popup-cpp.html#QMouseEvent">popup/popup.cpp</a>
<a href="qmag-qmag-cpp.html#QMouseEvent">qmag/qmag.cpp</a>
<a href="scrollview-scrollview-cpp.html#QMouseEvent">scrollview/scrollview.cpp</a>
<a href="trivial-trivial-cpp.html#QMouseEvent">trivial/trivial.cpp</a>
<a href="movies-main-cpp.html#QMouseEvent">movies/main.cpp</a>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="e49f8c"></a>QMouseEvent::QMouseEvent(<a href="qevent.html#Type">Type</a>type, const<a href="qpoint.html">QPoint</a>&pos, const<a href="qpoint.html">QPoint</a>&globalPos, intbutton, intstate)</h3>
<p>Constructs a mouse event object.
<p>The <em>type</em> parameter must be <code>QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick</code> or <code>QEvent::MouseMove.</code>
<p>The <em>pos</em> parameter specifies the position relative to the
receiving widget; <em>globalPos</em> is the position in absolute
coordinates; <em>button</em> specifies the <a href="qt.html#ButtonState">ButtonState</a> of the button that
caused the event, which should be 0 if <em>type</em> is <code>MouseMove;</code> and
<em>state</em> is the ButtonState at the time of the event.
<h3 class="fn"><a name="6d471e"></a>QMouseEvent::QMouseEvent(<a href="qevent.html#Type">Type</a>type, const<a href="qpoint.html">QPoint</a>&pos, intbutton, intstate)</h3>
<p>Constructs a mouse event object.
<p>The <em>type</em> parameter must be one of <code>QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick</code> or <code>QEvent::MouseMove.</code>
<p>The <em>pos</em> parameter specifies the position relative to the
receiving widget; <em>button</em> specifies the <a href="qt.html#ButtonState">ButtonState</a> of the button
that caused the event, which should be 0 if <em>type</em> is <code>MouseMove;</code> <em>state</em> is the ButtonState at the time of the event.
<p>The <a href="#3f4ad0">globalPos</a>() is initialized to <a href="qcursor.html#5bce2b">QCursor::pos</a>(), which may not be
appropriate. Use the other constructor to specify the global position
explicitly.
<h3 class="fn"><a href="qt.html#ButtonState">ButtonState</a><a name="78482f"></a>QMouseEvent::button()const</h3>
<p>Returns the button that caused the event.
<p>Possible return values are <code>LeftButton, RightButton, MidButton</code> and
<code>NoButton.</code>
<p>Note that the returned value is always <code>NoButton</code> (0) for mouse move
events.
<p>See also <a href="#db99dc">state</a>().
<p>Examples:
<a href="movies-main-cpp.html#button">movies/main.cpp</a>
<h3 class="fn">const<a href="qpoint.html">QPoint</a>&<a name="3f4ad0"></a>QMouseEvent::globalPos()const</h3>
<p>Returns the global position of the mouse pointer <em>at the time</em> of the event. This is important on asynchronous window systems
like X11: Whenever you move your widgets around in response to mouse
evens, globalPos() can differ a lot from the current pointer
position <a href="qcursor.html#5bce2b">QCursor::pos</a>(), and from
<code> <a href="qwidget.html#eb4b9c">QWidget::mapToGlobal</a>( <a href="#ac6f25">pos</a>() ) </code>.
<p>See also <a href="#53ffae">globalX</a>() and <a href="#48cb99">globalY</a>().
<h3 class="fn">int<a name="53ffae"></a>QMouseEvent::globalX()const</h3>
<p>Returns the global X position of the mouse pointer at the time of the event
<p>See also <a href="#48cb99">globalY</a>() and <a href="#3f4ad0">globalPos</a>().
<h3 class="fn">int<a name="48cb99"></a>QMouseEvent::globalY()const</h3>
<p>Returns the global Y position of the mouse pointer at the time of the event
<p>See also <a href="#53ffae">globalX</a>() and <a href="#3f4ad0">globalPos</a>().
<h3 class="fn">const<a href="qpoint.html">QPoint</a>&<a name="ac6f25"></a>QMouseEvent::pos()const</h3>
<p>Returns the position of the mouse pointer, relative to the widget that
received the event.
<p>If you move the widget as a result of the mouse event, use the
global position returned by <a href="#3f4ad0">globalPos</a>() to avoid a shaking motion.
<p>See also <a href="#07ad9e">x</a>(), <a href="#b63f4c">y</a>() and <a href="#3f4ad0">globalPos</a>().
<p>Examples:
<a href="qtimage-qtimage-cpp.html#pos">qtimage/qtimage.cpp</a>
<a href="drawlines-connect-cpp.html#pos">drawlines/connect.cpp</a>
<a href="qmag-qmag-cpp.html#pos">qmag/qmag.cpp</a>
<h3 class="fn"><a href="qt.html#ButtonState">ButtonState</a><a name="db99dc"></a>QMouseEvent::state()const</h3>
<p>Returns the button state (a combination of mouse buttons and keyboard
modifiers), i.e. what buttons and keys were being held depressed
immediately before the event was generated.
<p>Note that this means that for <code>QEvent::MouseButtonPress</code> and <code>QEvent::MouseButtonDblClick,</code> the flag for the <a href="#78482f">button</a>() itself will not be
set in the state; while for <code>QEvent::MouseButtonRelease,</code> it will.
<p>This value is mainly interesting for <code>QEvent::MouseMove,</code> for the
other cases, button() is more useful.
<p>The returned value is <code>LeftButton, RightButton, MidButton, ShiftButton, ControlButton</code> and <code>AltButton</code> OR'ed together.
<p>See also <a href="#78482f">button</a>() and <a href="#acd7fe">stateAfter</a>().
<p>Examples:
<a href="movies-main-cpp.html#state">movies/main.cpp</a>
<h3 class="fn"><a href="qt.html#ButtonState">ButtonState</a><a name="acd7fe"></a>QMouseEvent::stateAfter()const</h3>
<p>Returns the state of buttons after the event.
<p>See also <a href="#db99dc">state</a>().
<h3 class="fn">int<a name="07ad9e"></a>QMouseEvent::x()const</h3>
<p>Returns the X position of the mouse pointer, relative to the widget that
received the event.
<p>See also <a href="#b63f4c">y</a>() and <a href="#ac6f25">pos</a>().
<p>Examples:
<a href="scrollview-scrollview-cpp.html#x">scrollview/scrollview.cpp</a>
<h3 class="fn">int<a name="b63f4c"></a>QMouseEvent::y()const</h3>
<p>Returns the Y position of the mouse pointer, relative to the widget that
received the event.
<p>See also <a href="#07ad9e">x</a>() and <a href="#ac6f25">pos</a>().
<p>Examples:
<a href="scrollview-scrollview-cpp.html#y">scrollview/scrollview.cpp</a>
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|