Qt automatically grabs the mouse when a mouse button is pressed inside a widget; the widget will continue to receive mouse events until the last mouse button is released.
.PP
A mouse event contains a special accept flag that indicates whether the receiver wants the event. You should call QMouseEvent::ignore() if the mouse event is not handled by your widget. A mouse event is propagated up the parent widget chain until a widget accepts it with QMouseEvent::accept() or an event filter consumes it.
.PP
The functions pos(), x() and y() 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 globalPos() to avoid a shaking motion.
The \fIpos\fR parameter specifies the position relative to the receiving widget. \fIbutton\fR specifies the button that caused the event, which should be TQt::NoButton (0), if \fItype\fR is MouseMove. \fIstate\fR is the ButtonState at the time of the event.
The \fIpos\fR parameter specifies the position relative to the receiving widget. \fIglobalPos\fR is the position in absolute coordinates. \fIbutton\fR specifies the button that caused the event, which should be TQt::NoButton (0), if \fItype\fR is MouseMove. \fIstate\fR is the ButtonState at the time of the event.
Returns the global position of the mouse pointer \fIat the time of the event\fR. This is important on asynchronous window systems like X11. Whenever you move your widgets around in response to mouse events, globalPos() may differ a lot from the current pointer position QCursor::pos(), and from TQWidget::mapToGlobal( pos() ).
Returns the position of the mouse pointer relative to the widget that received the event.
.PP
If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.
.PP
See also x(), y(), and globalPos().
.PP
Examples:
.)l chart/canvasview.cpp, drawlines/connect.cpp, life/life.cpp, popup/popup.cpp, qmag/qmag.cpp, t14/cannon.cpp, and tooltip/tooltip.cpp.
.SH "ButtonState QMouseEvent::state () const"
Returns the button state (a combination of mouse buttons and keyboard modifiers), i.e. what buttons and keys were being pressed immediately before the event was generated.
This means that if you have a TQEvent::MouseButtonPress or a TQEvent::MouseButtonDblClick state() will \fInot\fR include the mouse button that's pressed. But once the mouse button has been released, the TQEvent::MouseButtonRelease event will have the button() that was pressed.