QWheelEvent Class Reference

#include <qevent.h>

Inheritance diagram for QWheelEvent:

Inheritance graph
[legend]
Collaboration diagram for QWheelEvent:

Collaboration graph
[legend]
List of all members.

Detailed Description

The QWheelEvent class contains parameters that describe a wheel event.

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.

See also:
QMouseEvent QWidget::grabMouse()

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 QPointpos () const
const QPointglobalPos () 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


Constructor & Destructor Documentation

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.

See also:
pos() delta() state()

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.

See also:
pos() globalPos() delta() state()

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 (  ) 

Definition at line 434 of file qevent.cpp.

00435 {
00436 }


Member Function Documentation

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.

See also:
x() y() globalPos()

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().

See also:
globalX() globalY()

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]

Returns the x position of the mouse cursor, relative to the widget that received the event.

See also:
y() pos()

Definition at line 116 of file qevent.h.

References p.

Referenced by QVFbView::wheelEvent().

00116 { return p.x(); }

int QWheelEvent::y (  )  const [inline]

Returns the y position of the mouse cursor, relative to the widget that received the event.

See also:
x() pos()

Definition at line 117 of file qevent.h.

References p.

Referenced by QVFbView::wheelEvent().

00117 { return p.y(); }

int QWheelEvent::globalX (  )  const [inline]

Returns the global x position of the mouse cursor at the time of the event.

See also:
globalY() globalPos()

Definition at line 118 of file qevent.h.

References g.

00118 { return g.x(); }

int QWheelEvent::globalY (  )  const [inline]

Returns the global y position of the mouse cursor at the time of the event.

See also:
globalX() globalPos()

Definition at line 119 of file qevent.h.

References g.

00119 { return g.y(); }

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; }


Member Data Documentation

QPoint QWheelEvent::p [protected]

Definition at line 133 of file qevent.h.

QPoint QWheelEvent::g [protected]

Definition at line 134 of file qevent.h.

Referenced by QWheelEvent().

int QWheelEvent::d [protected]

Reimplemented from QEvent.

Definition at line 135 of file qevent.h.

Qt::MouseButtons QWheelEvent::mouseState [protected]

Definition at line 136 of file qevent.h.

Qt::Orientation QWheelEvent::o [protected]

Definition at line 137 of file qevent.h.


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 19:47:41 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1