source: trunk/doc/html/qmouseevent.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 13.8 KB
RevLine 
[190]1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qevent.cpp:244 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QMouseEvent Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QMouseEvent Class Reference</h1>
33
34<p>The QMouseEvent class contains parameters that describe a mouse event.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qevent-h.html">qevent.h</a>&gt;</tt>
37<p>Inherits <a href="qevent.html">QEvent</a>.
38<p><a href="qmouseevent-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QMouseEvent"><b>QMouseEvent</b></a> ( Type&nbsp;type, const&nbsp;QPoint&nbsp;&amp;&nbsp;pos, int&nbsp;button, int&nbsp;state )</li>
42<li class=fn><a href="#QMouseEvent-2"><b>QMouseEvent</b></a> ( Type&nbsp;type, const&nbsp;QPoint&nbsp;&amp;&nbsp;pos, const&nbsp;QPoint&nbsp;&amp;&nbsp;globalPos, int&nbsp;button, int&nbsp;state )</li>
43<li class=fn>const QPoint &amp; <a href="#pos"><b>pos</b></a> () const</li>
44<li class=fn>const QPoint &amp; <a href="#globalPos"><b>globalPos</b></a> () const</li>
45<li class=fn>int <a href="#x"><b>x</b></a> () const</li>
46<li class=fn>int <a href="#y"><b>y</b></a> () const</li>
47<li class=fn>int <a href="#globalX"><b>globalX</b></a> () const</li>
48<li class=fn>int <a href="#globalY"><b>globalY</b></a> () const</li>
49<li class=fn>ButtonState <a href="#button"><b>button</b></a> () const</li>
50<li class=fn>ButtonState <a href="#state"><b>state</b></a> () const</li>
51<li class=fn>ButtonState <a href="#stateAfter"><b>stateAfter</b></a> () const</li>
52<li class=fn>bool <a href="#isAccepted"><b>isAccepted</b></a> () const</li>
53<li class=fn>void <a href="#accept"><b>accept</b></a> ()</li>
54<li class=fn>void <a href="#ignore"><b>ignore</b></a> ()</li>
55</ul>
56<hr><a name="details"></a><h2>Detailed Description</h2>
57
58
59
60<p> The QMouseEvent class contains parameters that describe a mouse event.
61<p> Mouse events occur when a mouse button is pressed or released
62inside a widget or when the mouse cursor is moved.
63<p> Mouse move events will occur only when a mouse button is pressed
64down, unless mouse tracking has been enabled with
65<a href="qwidget.html#setMouseTracking">QWidget::setMouseTracking</a>().
66<p> Qt automatically grabs the mouse when a mouse button is pressed
67inside a widget; the widget will continue to receive mouse events
68until the last mouse button is released.
69<p> A mouse event contains a special accept flag that indicates
70whether the receiver wants the event. You should call
71<a href="#ignore">QMouseEvent::ignore</a>() if the mouse event is not handled by your
72widget. A mouse event is propagated up the parent widget chain
73until a widget accepts it with <a href="#accept">QMouseEvent::accept</a>() or an event
74filter consumes it.
75<p> The functions <a href="#pos">pos</a>(), <a href="#x">x</a>() and <a href="#y">y</a>() give the cursor position relative
76to the widget that receives the mouse event. If you move the
77widget as a result of the mouse event, use the global position
78returned by <a href="#globalPos">globalPos</a>() to avoid a shaking motion.
79<p> The <a href="qwidget.html#setEnabled">QWidget::setEnabled</a>() function can be used to enable or
80disable mouse and keyboard events for a widget.
81<p> The event handlers <a href="qwidget.html#mousePressEvent">QWidget::mousePressEvent</a>(),
82<a href="qwidget.html#mouseReleaseEvent">QWidget::mouseReleaseEvent</a>(), <a href="qwidget.html#mouseDoubleClickEvent">QWidget::mouseDoubleClickEvent</a>() and
83<a href="qwidget.html#mouseMoveEvent">QWidget::mouseMoveEvent</a>() receive mouse events.
84<p> <p>See also <a href="qwidget.html#mouseTracking-prop">QWidget::mouseTracking</a>, <a href="qwidget.html#grabMouse">QWidget::grabMouse</a>(), <a href="qcursor.html#pos">QCursor::pos</a>(), and <a href="events.html">Event Classes</a>.
85
86<hr><h2>Member Function Documentation</h2>
87<h3 class=fn><a name="QMouseEvent"></a>QMouseEvent::QMouseEvent ( <a href="qevent.html#Type-enum">Type</a>&nbsp;type, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos, int&nbsp;button, int&nbsp;state )
88</h3>
89
90<p> Constructs a mouse event object.
91<p> The <em>type</em> parameter must be one of <a href="qevent.html#Type-enum">QEvent::MouseButtonPress</a>,
92<a href="qevent.html#Type-enum">QEvent::MouseButtonRelease</a>, <a href="qevent.html#Type-enum">QEvent::MouseButtonDblClick</a> or
93<a href="qevent.html#Type-enum">QEvent::MouseMove</a>.
94<p> The <em>pos</em> parameter specifies the position relative to the
95receiving widget. <em>button</em> specifies the <a href="qt.html#ButtonState-enum">button</a> that caused the event, which should be <a href="qt.html#ButtonState-enum">Qt::NoButton</a> (0), if <em>type</em> is <a href="qevent.html#Type-enum">MouseMove</a>. <em>state</em> is the
96<a href="qt.html#ButtonState-enum">ButtonState</a> at the time of the
97event.
98<p> The <a href="#globalPos">globalPos</a>() is initialized to <a href="qcursor.html#pos">QCursor::pos</a>(), which may not be
99appropriate. Use the other constructor to specify the global
100position explicitly.
101
102<h3 class=fn><a name="QMouseEvent-2"></a>QMouseEvent::QMouseEvent ( <a href="qevent.html#Type-enum">Type</a>&nbsp;type, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;globalPos, int&nbsp;button, int&nbsp;state )
103</h3>
104
105<p> Constructs a mouse event object.
106<p> The <em>type</em> parameter must be <a href="qevent.html#Type-enum">QEvent::MouseButtonPress</a>, <a href="qevent.html#Type-enum">QEvent::MouseButtonRelease</a>, <a href="qevent.html#Type-enum">QEvent::MouseButtonDblClick</a> or <a href="qevent.html#Type-enum">QEvent::MouseMove</a>.
107<p> The <em>pos</em> parameter specifies the position relative to the
108receiving widget. <em>globalPos</em> is the position in absolute
109coordinates. <em>button</em> specifies the <a href="qt.html#ButtonState-enum">button</a> that caused the event, which should be <a href="qt.html#ButtonState-enum">Qt::NoButton</a> (0), if <em>type</em> is <a href="qevent.html#Type-enum">MouseMove</a>. <em>state</em> is the
110<a href="qt.html#ButtonState-enum">ButtonState</a> at the time of the
111event.
112<p>
113<h3 class=fn>void <a name="accept"></a>QMouseEvent::accept ()
114</h3>
115
116<p> Sets the accept flag of the mouse event object.
117<p> Setting the accept parameter indicates that the receiver of the
118event wants the mouse event. Unwanted mouse events are sent to the
119parent widget.
120<p> The accept flag is set by default.
121<p> <p>See also <a href="#ignore">ignore</a>().
122
123<h3 class=fn><a href="qt.html#ButtonState-enum">ButtonState</a> <a name="button"></a>QMouseEvent::button () const
124</h3>
125
126<p> Returns the button that caused the event.
127<p> Possible return values are <a href="qt.html#ButtonState-enum">LeftButton</a>, <a href="qt.html#ButtonState-enum">RightButton</a>, <a href="qt.html#ButtonState-enum">MidButton</a> and <a href="qt.html#ButtonState-enum">NoButton</a>.
128<p> Note that the returned value is always <a href="qt.html#ButtonState-enum">NoButton</a> for mouse move
129events.
130<p> <p>See also <a href="#state">state</a>() and <a href="qt.html#ButtonState-enum">Qt::ButtonState</a>.
131
132<p>Examples: <a href="dclock-example.html#x1101">dclock/dclock.cpp</a>, <a href="life-example.html#x1890">life/life.cpp</a>, and <a href="tutorial1-14.html#x2417">t14/cannon.cpp</a>.
133<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp; <a name="globalPos"></a>QMouseEvent::globalPos () const
134</h3>
135
136<p> Returns the global position of the mouse pointer <em>at the time of the event</em>. This is important on asynchronous window systems
137like X11. Whenever you move your widgets around in response to
138mouse events, <a href="#globalPos">globalPos</a>() may differ a lot from the current
139pointer position <a href="qcursor.html#pos">QCursor::pos</a>(), and from <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>(
140<a href="#pos">pos</a>() ).
141<p> <p>See also <a href="#globalX">globalX</a>() and <a href="#globalY">globalY</a>().
142
143<p>Example: <a href="aclock-example.html#x1181">aclock/aclock.cpp</a>.
144<h3 class=fn>int <a name="globalX"></a>QMouseEvent::globalX () const
145</h3>
146
147<p> Returns the global x-position of the mouse pointer at the time of
148the event.
149<p> <p>See also <a href="#globalY">globalY</a>() and <a href="#globalPos">globalPos</a>().
150
151<h3 class=fn>int <a name="globalY"></a>QMouseEvent::globalY () const
152</h3>
153
154<p> Returns the global y-position of the mouse pointer at the time of
155the event.
156<p> <p>See also <a href="#globalX">globalX</a>() and <a href="#globalPos">globalPos</a>().
157
158<h3 class=fn>void <a name="ignore"></a>QMouseEvent::ignore ()
159</h3>
160
161<p> Clears the accept flag parameter of the mouse event object.
162<p> Clearing the accept parameter indicates that the event receiver
163does not want the mouse event. Unwanted mouse events are sent to
164the parent widget.
165<p> The accept flag is set by default.
166<p> <p>See also <a href="#accept">accept</a>().
167
168<h3 class=fn>bool <a name="isAccepted"></a>QMouseEvent::isAccepted () const
169</h3>
170
171<p> Returns TRUE if the receiver of the event wants to keep the key;
172otherwise returns FALSE.
173
174<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp; <a name="pos"></a>QMouseEvent::pos () const
175</h3>
176
177<p> Returns the position of the mouse pointer relative to the widget
178that received the event.
179<p> If you move the widget as a result of the mouse event, use the
180global position returned by <a href="#globalPos">globalPos</a>() to avoid a shaking motion.
181<p> <p>See also <a href="#x">x</a>(), <a href="#y">y</a>(), and <a href="#globalPos">globalPos</a>().
182
183<p>Examples: <a href="tutorial2-06.html#x2580">chart/canvasview.cpp</a>, <a href="drawlines-example.html#x1654">drawlines/connect.cpp</a>, <a href="life-example.html#x1891">life/life.cpp</a>, <a href="popup-example.html#x1611">popup/popup.cpp</a>, <a href="qmag-example.html#x1780">qmag/qmag.cpp</a>, <a href="tutorial1-14.html#x2418">t14/cannon.cpp</a>, and <a href="tooltip-example.html#x443">tooltip/tooltip.cpp</a>.
184<h3 class=fn><a href="qt.html#ButtonState-enum">ButtonState</a> <a name="state"></a>QMouseEvent::state () const
185</h3>
186
187<p> Returns the button state (a combination of mouse buttons and
188keyboard modifiers), i.e. what buttons and keys were being pressed
189immediately before the event was generated.
190<p> This means that if you have a <a href="qevent.html#Type-enum">QEvent::MouseButtonPress</a> or a <a href="qevent.html#Type-enum">QEvent::MouseButtonDblClick</a> <a href="#state">state</a>() will <em>not</em> include the mouse
191button that's pressed. But once the mouse button has been
192released, the <a href="qevent.html#Type-enum">QEvent::MouseButtonRelease</a> event will have the
193<a href="#button">button</a>() that was pressed.
194<p> This value is mainly interesting for <a href="qevent.html#Type-enum">QEvent::MouseMove</a>; for the
195other cases, button() is more useful.
196<p> The returned value is <a href="qt.html#ButtonState-enum">LeftButton</a>, <a href="qt.html#ButtonState-enum">RightButton</a>, <a href="qt.html#ButtonState-enum">MidButton</a>,
197<a href="qt.html#ButtonState-enum">ShiftButton</a>, <a href="qt.html#ButtonState-enum">ControlButton</a> and <a href="qt.html#ButtonState-enum">AltButton</a> OR'ed together.
198<p> <p>See also <a href="#button">button</a>(), <a href="#stateAfter">stateAfter</a>(), and <a href="qt.html#ButtonState-enum">Qt::ButtonState</a>.
199
200<p>Examples: <a href="popup-example.html#x1612">popup/popup.cpp</a> and <a href="showimg-example.html#x1334">showimg/showimg.cpp</a>.
201<h3 class=fn><a href="qt.html#ButtonState-enum">ButtonState</a> <a name="stateAfter"></a>QMouseEvent::stateAfter () const
202</h3>
203
204<p> Returns the state of buttons after the event.
205<p> <p>See also <a href="#state">state</a>() and <a href="qt.html#ButtonState-enum">Qt::ButtonState</a>.
206
207<h3 class=fn>int <a name="x"></a>QMouseEvent::x () const
208</h3>
209
210<p> Returns the x-position of the mouse pointer, relative to the
211widget that received the event.
212<p> <p>See also <a href="#y">y</a>() and <a href="#pos">pos</a>().
213
214<p>Example: <a href="showimg-example.html#x1335">showimg/showimg.cpp</a>.
215<h3 class=fn>int <a name="y"></a>QMouseEvent::y () const
216</h3>
217
218<p> Returns the y-position of the mouse pointer, relative to the
219widget that received the event.
220<p> <p>See also <a href="#x">x</a>() and <a href="#pos">pos</a>().
221
222<p>Example: <a href="showimg-example.html#x1336">showimg/showimg.cpp</a>.
223<!-- eof -->
224<hr><p>
225This file is part of the <a href="index.html">Qt toolkit</a>.
226Copyright &copy; 1995-2007
227<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
228<table width=100% cellspacing=0 border=0><tr>
229<td>Copyright &copy; 2007
230<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
231<td align=right><div align=right>Qt 3.3.8</div>
232</table></div></address></body>
233</html>
Note: See TracBrowser for help on using the repository browser.