![]() |
Home · Overviews · Examples |
The QMouseEvent class contains parameters that describe a mouse event. More...
Inherits QInputEvent.
The QMouseEvent class contains parameters that describe a mouse event.
Mouse events occur when a mouse button is pressed or released inside a widget, or when the mouse cursor is moved.
Mouse move events will occur only when a mouse button is pressed down, unless mouse tracking has been enabled with QWidget::setMouseTracking().
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.
A mouse event contains a special accept flag that indicates whether the receiver wants the event. You should call 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 accept, or an event filter consumes it.
The state of the keyboard modifier keys can be found by calling the modifiers() function, inhertied from QInputEvent.
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 QWidget::setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.
Reimplement the QWidget event handlers, QWidget::mousePressEvent(), QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(), and QWidget::mouseMoveEvent() to receive mouse events in your own widgets.
QCursor::pos()
See also QWidget::setMouseTracking and QWidget::grabMouse.
Copyright © 2008 Trolltech | Trademarks | Qt Jambi 4.3.5_01 |