|
| QWheelEvent (const QPointF &pos, const QPointF &globalPosition, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orientation=Qt::Vertical) |
|
| QWheelEvent (const QPointF &pos, const QPointF &globalPosition, QPoint pixelDelta, QPoint angleDelta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized) |
|
| QWheelEvent (const QPointF &pos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orientation=Qt::Vertical) |
|
QPoint | angleDelta () const |
|
Qt::MouseButtons | buttons () const |
|
int | delta () const |
|
QPoint | globalPos () const |
|
const QPointF & | globalPosF () const |
|
int | globalX () const |
|
int | globalY () const |
|
Qt::Orientation | orientation () const |
|
Qt::ScrollPhase | phase () const |
|
QPoint | pixelDelta () const |
|
QPoint | pos () const |
|
const QPointF & | posF () const |
|
Qt::MouseEventSource | source () const |
|
int | x () const |
|
int | y () const |
|
Qt::KeyboardModifiers | modifiers () const |
|
void | setModifiers (Qt::KeyboardModifiers modifiers) |
|
void | setTimestamp (ulong timestamp) |
|
ulong | timestamp () const |
|
| QEvent (const QEvent &other) |
|
| QEvent (Type type) |
|
virtual | ~QEvent () |
|
void | accept () |
|
void | ignore () |
|
bool | isAccepted () const |
|
QEvent & | operator= (const QEvent &other) |
|
void | setAccepted (bool accepted) |
|
bool | spontaneous () const |
|
Type | type () const |
|
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 methods 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() method 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()
Constructs a wheel event object.
The position pos is the location of the mouse cursor within the widget. This constructor does not provide a way to set the global position, it is initialized to the result of QCursor::pos(). Use one of the other constructors if you need to specify the global position explicitly.
The buttons describe the state of the mouse buttons at the time of the event. The value for the delta contains the rotation distance, modifiers holds the keyboard modifier flags at the time of the event, and orientation holds the wheel's orientation.
- See also
- buttons(), delta(), pos()
Constructs a wheel event object.
The position pos provides the location of the mouse cursor within the window. The position in global coordinates is specified by globalPosition. The value for pixelDelta contains the scrolling distance in pixels on screen while angleDelta contains the wheel rotation distance. The value of pixelDelta can be null. The mouse and keyboard states at the time of the event are specified by buttons and modifiers. The scrolling phase of the event is specified by phase.
If the wheel event comes from a physical mouse wheel, source is set to Qt::MouseEventNotSynthesized. If it comes from a gesture detected by the operating system, or from a non-mouse hardware device, such that pixelDelta is directly related to finger movement, source is set to Qt::MouseEventSynthesizedBySystem. If it comes from CopperSpice the source will be set to Qt::MouseEventSynthesizedByCS.
- See also
- posF(), globalPosF(), angleDelta(), pixelDelta(), phase()
QPoint QWheelEvent::angleDelta |
( |
| ) |
const |
|
inline |
Returns the distance that the wheel is rotated, in eighths 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 since 120 units * 1/8 = 15 degrees.
However, some mice have finer-resolution wheels and send delta values that are less than 120 units (less than 15 degrees). To support this possibility, you can either cumulatively add the delta values from events until the value of 120 is reached, then scroll the widget, or you can partially scroll the widget in response to each wheel event.
QPoint numPixels =
event->pixelDelta();
QPoint numDegrees =
event->angleDelta() / 8;
scrollWithPixels(numPixels);
}
else if (!numDegrees.
isNull()) {
QPoint numSteps = numDegrees / 15;
scrollWithDegrees(numSteps);
}
event->accept();
}
On platforms which support scrolling phases the delta may be null when either of these conditions is true.
- Scrolling is about to begin but the distance did not yet change (Qt::ScrollBegin)
- Scrolling has ended and the distance did not change anymore (Qt::ScrollEnd)
- See also
- pixelDelta()
int QWheelEvent::delta |
( |
| ) |
const |
|
inline |
Returns the distance that the wheel is rotated in eighths 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 since 120 units * 1/8 = 15 degrees.
Some mice have finer-resolution wheels and send delta values that are less than 120 units (less than 15 degrees). To support this possibility, you can either cumulatively add the delta values from events until the value of 120 is reached, then scroll the widget, or you can partially scroll the widget in response to each wheel event.
int numDegrees = event->delta() / 8;
int numSteps = numDegrees / 15;
if (event->orientation() == Qt::Horizontal) {
scrollHorizontally(numSteps);
} else {
scrollVertically(numSteps);
}
event->accept();
}