#include <qevent.h>
Inheritance diagram for QWheelEvent:


Wheel events are sent to the widget under the mouse cursor, but if that widget does not handle the event they are sent to the focus widget. The rotation distance is provided by delta(). The functions pos() and globalPos() return the mouse cursor's location at the time of the event.
A wheel event contains a special accept flag that indicates whether the receiver wants the event. You should call ignore() if you do not handle the wheel event; this ensures that it will be sent to the parent widget.
The QWidget::setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.
The event handler QWidget::wheelEvent() receives wheel events.
Definition at line 102 of file qevent.h.
Public Member Functions | |
| QWheelEvent (const QPoint &pos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient=Qt::Vertical) | |
| QWheelEvent (const QPoint &pos, const QPoint &globalPos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient=Qt::Vertical) | |
| ~QWheelEvent () | |
| int | delta () const |
| const QPoint & | pos () const |
| const QPoint & | globalPos () const |
| int | x () const |
| int | y () const |
| int | globalX () const |
| int | globalY () const |
| Qt::MouseButtons | buttons () const |
| Qt::Orientation | orientation () const |
Protected Attributes | |
| QPoint | p |
| QPoint | g |
| int | d |
| Qt::MouseButtons | mouseState |
| Qt::Orientation | o |
| QWheelEvent::QWheelEvent | ( | const QPoint & | pos, | |
| int | delta, | |||
| Qt::MouseButtons | buttons, | |||
| Qt::KeyboardModifiers | modifiers, | |||
| Qt::Orientation | orient = Qt::Vertical | |||
| ) |
Constructs a wheel event object.
The position, pos, is the location of the mouse cursor within the widget. The globalPos() is initialized to QCursor::pos() which is usually, but not always, correct. Use the other constructor if you need to specify the global position explicitly.
The buttons describe the state of the mouse buttons at the time of the event, delta contains the rotation distance, modifiers holds the keyboard modifier flags at the time of the event, and orient holds the wheel's orientation.
Definition at line 423 of file qevent.cpp.
References g, and QCursor::pos().
00426 : QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient) 00427 { 00428 g = QCursor::pos(); 00429 }
Here is the call graph for this function:

| QWheelEvent::QWheelEvent | ( | const QPoint & | pos, | |
| const QPoint & | globalPos, | |||
| int | delta, | |||
| Qt::MouseButtons | buttons, | |||
| Qt::KeyboardModifiers | modifiers, | |||
| Qt::Orientation | orient = Qt::Vertical | |||
| ) |
Constructs a wheel event object.
The pos provides the location of the mouse cursor within the widget. The position in global coordinates is specified by globalPos. delta contains the rotation distance, modifiers holds the keyboard modifier flags at the time of the event, and orient holds the wheel's orientation.
Definition at line 462 of file qevent.cpp.
00465 : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient) 00466 {}
| QWheelEvent::~QWheelEvent | ( | ) |
| int QWheelEvent::delta | ( | ) | const [inline] |
Returns the distance that the wheel is rotated, in eights of a degree. A positive value indicates that the wheel was rotated forwards away from the user; a negative value indicates that the wheel was rotated backwards toward the user.
Most mouse types work in steps of 15 degrees, in which case the delta value is a multiple of 120 (== 15 * 8).
Example:
void MyWidget::wheelEvent(QWheelEvent *event) { int numDegrees = event->delta() / 8; int numSteps = numDegrees / 15; if (event->orientation() == Qt::Horizontal) { scrollHorizontally(numSteps); } else { scrollVertically(numSteps); } }
Definition at line 113 of file qevent.h.
References d.
Referenced by Q3TextEdit::contentsWheelEvent(), Q3Table::eventFilter(), Q3ScrollView::viewportWheelEvent(), Q3SpinWidget::wheelEvent(), QTextEdit::wheelEvent(), Q3ComboBox::wheelEvent(), QAbstractSlider::wheelEvent(), QMenu::wheelEvent(), GLWidget::wheelEvent(), SvgNativeView::wheelEvent(), XFormView::wheelEvent(), QVFbView::wheelEvent(), SvgGLView::wheelEvent(), QView3DWidget::wheelEvent(), QComboBox::wheelEvent(), Q3ScrollView::wheelEvent(), and SvgRasterView::wheelEvent().
00113 { return d; }
| const QPoint & QWheelEvent::pos | ( | ) | const [inline] |
Returns the position of the mouse cursor relative to the widget that received the event.
If you move your widgets around in response to mouse events, use globalPos() instead of this function.
Definition at line 114 of file qevent.h.
References p.
Referenced by Q3ScrollView::viewportWheelEvent(), QAbstractSlider::wheelEvent(), QDateTimeSpinWidget::wheelEvent(), and QMenu::wheelEvent().
00114 { return p; }
| const QPoint & QWheelEvent::globalPos | ( | ) | const [inline] |
Returns the global position of the mouse pointer {at the time of the event}. This is important on asynchronous window systems such as X11; whenever you move your widgets around in response to mouse events, globalPos() can differ a lot from the current cursor position returned by QCursor::pos().
Definition at line 115 of file qevent.h.
References g.
Referenced by Q3ScrollView::viewportWheelEvent(), and Q3ScrollView::wheelEvent().
00115 { return g; }
| int QWheelEvent::x | ( | ) | const [inline] |
| int QWheelEvent::y | ( | ) | const [inline] |
| int QWheelEvent::globalX | ( | ) | const [inline] |
| int QWheelEvent::globalY | ( | ) | const [inline] |
| Qt::MouseButtons QWheelEvent::buttons | ( | ) | const [inline] |
Returns the mouse state when the event occurred.
Definition at line 121 of file qevent.h.
Referenced by QVFbView::wheelEvent().
00121 { return mouseState; }
| Qt::Orientation QWheelEvent::orientation | ( | ) | const [inline] |
Returns the wheel's orientation.
Definition at line 122 of file qevent.h.
References o.
Referenced by QAbstractSlider::wheelEvent(), and Q3ScrollView::wheelEvent().
00122 { return o; }
QPoint QWheelEvent::p [protected] |
QPoint QWheelEvent::g [protected] |
int QWheelEvent::d [protected] |
Qt::MouseButtons QWheelEvent::mouseState [protected] |
Qt::Orientation QWheelEvent::o [protected] |
1.5.1