pub struct WheelEvent<'a> { /* private fields */ }
Expand description

Notice these docs are heavy WIP and not very relevent yet

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. Wheel events are generated for both mouse wheels and trackpad scroll gestures. There are two ways to read the wheel event delta: angleDelta() returns the delta in wheel degrees. This value is always provided. pixelDelta() returns the delta in screen pixels and is available on platforms that have high-resolution trackpads, such as MacOS . If that is the case, source() will return Qt::MouseEventSynthesizedBySystem.

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: MouseEvent Widget::grab_mouse

Licence

The documentation is an adoption of the original Qt Documentation and provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.

Implementations

Returns the scrolling distance in pixels on screen. This value is provided on platforms that support high-resolution pixel-based delta values, such as MacOS . The value should be used directly to scroll content on screen.

Example:

Note: On platforms that support scrolling phases , the delta may be null when:

  • scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
  • or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd). Note: On X11 this value is driver specific and unreliable, use angleDelta() instead

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; i.e., 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.

Example:

Note: On platforms that support scrolling phases , the delta may be null when:

  • scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
  • or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).

This function has been deprecated, use pixelDelta() or angleDelta() instead.

Returns the wheel’s orientation.

Use angleDelta() instead.

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()] [global_pos()]

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 globalPosF() instead of this function.

See also: [global_pos_f()]

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: [global_x()] [global_y()]

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, globalPosF() can differ a lot from the current cursor position returned by QCursor::pos().

See also: [pos_f()]

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

See also: [y()] [pos()]

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

See also: [x()] [pos()]

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

See also: [global_y()] [global_pos()]

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

See also: [global_x()] [global_pos()]

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 globalPosF() instead of this function.

See also: [global_pos_f()]

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, globalPosF() can differ a lot from the current cursor position returned by QCursor::pos().

See also: [pos_f()]

Returns the mouse state when the event occurred.

Returns the scrolling phase of this wheel event.

Note: The Qt::ScrollBegin and Qt::ScrollEnd phases are currently supported only on MacOS .

Returns whether the delta values delivered with the event are inverted.

Normally, a vertical wheel will produce a QWheelEvent with positive delta values if the top of the wheel is rotating away from the hand operating it. Similarly, a horizontal wheel movement will produce a QWheelEvent with positive delta values if the top of the wheel is moved to the left.

However, on some platforms this is configurable, so that the same operations described above will produce negative delta values (but with the same magnitude). With the inverted property a wheel event consumer can choose to always follow the direction of the wheel, regardless of the system settings, but only for specific widgets. (One such use case could be that the user is rotating the wheel in the same direction as a visual Tumbler rotates. Another usecase is to make a slider handle follow the direction of movement of fingers on a touchpad regardless of system configuration.)

Note: Many platforms provide no such information. On such platforms inverted always returns false.

Returns information about the wheel event source.

The source can be used to distinguish between events that come from a mouse with a physical wheel and events that are generated by some other means, such as a flick gesture on a touchpad.

Note: Many platforms provide no such information. On such platforms Qt::MouseEventNotSynthesized is returned always.

See also: [t::mouse_event_source()]

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.