1QMouseEvent(3qt) QMouseEvent(3qt)
2
3
4
6 QMouseEvent - Parameters that describe a mouse event
7
9 #include <qevent.h>
10
11 Inherits QEvent.
12
13 Public Members
14 QMouseEvent ( Type type, const QPoint & pos, int button, int state )
15 QMouseEvent ( Type type, const QPoint & pos, const QPoint & globalPos,
16 int button, int state )
17 const QPoint & pos () const
18 const QPoint & globalPos () const
19 int x () const
20 int y () const
21 int globalX () const
22 int globalY () const
23 ButtonState button () const
24 ButtonState state () const
25 ButtonState stateAfter () const
26 bool isAccepted () const
27 void accept ()
28 void ignore ()
29
31 The QMouseEvent class contains parameters that describe a mouse event.
32
33 Mouse events occur when a mouse button is pressed or released inside a
34 widget or when the mouse cursor is moved.
35
36 Mouse move events will occur only when a mouse button is pressed down,
37 unless mouse tracking has been enabled with
38 QWidget::setMouseTracking().
39
40 Qt automatically grabs the mouse when a mouse button is pressed inside
41 a widget; the widget will continue to receive mouse events until the
42 last mouse button is released.
43
44 A mouse event contains a special accept flag that indicates whether the
45 receiver wants the event. You should call QMouseEvent::ignore() if the
46 mouse event is not handled by your widget. A mouse event is propagated
47 up the parent widget chain until a widget accepts it with
48 QMouseEvent::accept() or an event filter consumes it.
49
50 The functions pos(), x() and y() give the cursor position relative to
51 the widget that receives the mouse event. If you move the widget as a
52 result of the mouse event, use the global position returned by
53 globalPos() to avoid a shaking motion.
54
55 The QWidget::setEnabled() function can be used to enable or disable
56 mouse and keyboard events for a widget.
57
58 The event handlers QWidget::mousePressEvent(),
59 QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent() and
60 QWidget::mouseMoveEvent() receive mouse events.
61
62 See also QWidget::mouseTracking, QWidget::grabMouse(), QCursor::pos(),
63 and Event Classes.
64
67 state )
68 Constructs a mouse event object.
69
70 The type parameter must be one of QEvent::MouseButtonPress,
71 QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick or
72 QEvent::MouseMove.
73
74 The pos parameter specifies the position relative to the receiving
75 widget. button specifies the button that caused the event, which should
76 be Qt::NoButton (0), if type is MouseMove. state is the ButtonState at
77 the time of the event.
78
79 The globalPos() is initialized to QCursor::pos(), which may not be
80 appropriate. Use the other constructor to specify the global position
81 explicitly.
82
84 globalPos, int button, int state )
85 Constructs a mouse event object.
86
87 The type parameter must be QEvent::MouseButtonPress,
88 QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick or
89 QEvent::MouseMove.
90
91 The pos parameter specifies the position relative to the receiving
92 widget. globalPos is the position in absolute coordinates. button
93 specifies the button that caused the event, which should be
94 Qt::NoButton (0), if type is MouseMove. state is the ButtonState at the
95 time of the event.
96
98 Sets the accept flag of the mouse event object.
99
100 Setting the accept parameter indicates that the receiver of the event
101 wants the mouse event. Unwanted mouse events are sent to the parent
102 widget.
103
104 The accept flag is set by default.
105
106 See also ignore().
107
109 Returns the button that caused the event.
110
111 Possible return values are LeftButton, RightButton, MidButton and
112 NoButton.
113
114 Note that the returned value is always NoButton for mouse move events.
115
116 See also state() and Qt::ButtonState.
117
118 Examples:
119
121 Returns the global position of the mouse pointer at the time of the
122 event. This is important on asynchronous window systems like X11.
123 Whenever you move your widgets around in response to mouse events,
124 globalPos() may differ a lot from the current pointer position
125 QCursor::pos(), and from QWidget::mapToGlobal( pos() ).
126
127 See also globalX() and globalY().
128
129 Example: aclock/aclock.cpp.
130
132 Returns the global x-position of the mouse pointer at the time of the
133 event.
134
135 See also globalY() and globalPos().
136
138 Returns the global y-position of the mouse pointer at the time of the
139 event.
140
141 See also globalX() and globalPos().
142
144 Clears the accept flag parameter of the mouse event object.
145
146 Clearing the accept parameter indicates that the event receiver does
147 not want the mouse event. Unwanted mouse events are sent to the parent
148 widget.
149
150 The accept flag is set by default.
151
152 See also accept().
153
155 Returns TRUE if the receiver of the event wants to keep the key;
156 otherwise returns FALSE.
157
159 Returns the position of the mouse pointer relative to the widget that
160 received the event.
161
162 If you move the widget as a result of the mouse event, use the global
163 position returned by globalPos() to avoid a shaking motion.
164
165 See also x(), y(), and globalPos().
166
167 Examples:
168
170 Returns the button state (a combination of mouse buttons and keyboard
171 modifiers), i.e. what buttons and keys were being pressed immediately
172 before the event was generated.
173
174 This means that if you have a QEvent::MouseButtonPress or a
175 QEvent::MouseButtonDblClick state() will not include the mouse button
176 that's pressed. But once the mouse button has been released, the
177 QEvent::MouseButtonRelease event will have the button() that was
178 pressed.
179
180 This value is mainly interesting for QEvent::MouseMove; for the other
181 cases, button() is more useful.
182
183 The returned value is LeftButton, RightButton, MidButton, ShiftButton,
184 ControlButton and AltButton OR'ed together.
185
186 See also button(), stateAfter(), and Qt::ButtonState.
187
188 Examples:
189
191 Returns the state of buttons after the event.
192
193 See also state() and Qt::ButtonState.
194
196 Returns the x-position of the mouse pointer, relative to the widget
197 that received the event.
198
199 See also y() and pos().
200
201 Example: showimg/showimg.cpp.
202
204 Returns the y-position of the mouse pointer, relative to the widget
205 that received the event.
206
207 See also x() and pos().
208
209 Example: showimg/showimg.cpp.
210
211
213 http://doc.trolltech.com/qmouseevent.html
214 http://www.trolltech.com/faq/tech.html
215
217 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
218 license file included in the distribution for a complete license
219 statement.
220
222 Generated automatically from the source code.
223
225 If you find a bug in Qt, please report it as described in
226 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
227 help you. Thank you.
228
229 The definitive Qt documentation is provided in HTML format; it is
230 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
231 web browser. This man page is provided as a convenience for those users
232 who prefer man pages, although this format is not officially supported
233 by Trolltech.
234
235 If you find errors in this manual page, please report them to qt-
236 bugs@trolltech.com. Please include the name of the manual page
237 (qmouseevent.3qt) and the Qt version (3.3.8).
238
239
240
241Trolltech AS 2 February 2007 QMouseEvent(3qt)