QNativeGestureEvent

The QNativeGestureEvent class contains parameters that describe a gesture event. More

Inheritance diagram of PySide6.QtGui.QNativeGestureEvent

Synopsis

Functions

Detailed Description

Native gesture events are generated by the operating system, typically by interpreting trackpad touch events. Gesture events are high-level events such as zoom, rotate or pan. Several types hold incremental values: that is, value() and delta() provide the difference from the previous event to the current event.

Event Type

Description

Touch sequence

ZoomNativeGesture

Magnification delta in percent.

macOS and Wayland: Two-finger pinch.

SmartZoomNativeGesture

Boolean magnification state.

macOS: Two-finger douple tap (trackpad) / One-finger douple tap (magic mouse).

RotateNativeGesture

Rotation delta in degrees.

macOS and Wayland: Two-finger rotate.

SwipeNativeGesture

Swipe angle in degrees.

macOS: Configurable in trackpad settings.

PanNativeGesture

Displacement delta in pixels.

Wayland: Three or more fingers moving as a group, in any direction.

In addition, BeginNativeGesture and EndNativeGesture are sent before and after gesture event streams:

BeginNativeGesture ZoomNativeGesture ZoomNativeGesture ZoomNativeGesture EndNativeGesture

The event stream may include interleaved gestures of different types: for example the two-finger pinch gesture generates a stream of Zoom and Rotate events, and PanNativeGesture may sometimes be interleaved with those, depending on the platform.

Other types are standalone events: SmartZoomNativeGesture and SwipeNativeGesture occur only once each time the gesture is detected.

Note

On a touchpad, moving two fingers as a group (the two-finger flick gesture) is usually reserved for scrolling; in that case, Qt generates QWheelEvents. This is the reason that three or more fingers are needed to generate a PanNativeGesture.

See also

NativeGestureType QGestureEvent QWheelEvent

class PySide6.QtGui.QNativeGestureEvent(type, dev, localPos, scenePos, globalPos, value, sequenceId, intArgument)

Note

This constructor is deprecated.

PySide6.QtGui.QNativeGestureEvent(type, dev, fingerCount, localPos, scenePos, globalPos, value, delta[, sequenceId=UINT64_MAX])

PySide6.QtGui.QNativeGestureEvent(arg__1)

Parameters

Use the other constructor, because intValue is no longer stored separately.

Constructs a native gesture event of type type originating from device.

The points localPos, scenePos and globalPos specify the gesture position relative to the receiving widget or item, window, and screen or desktop, respectively.

realValue is the macOS event parameter, sequenceId and intValue are the Windows event parameters.

Note

It’s not possible to store realValue and intValue simultaneously: one or the other must be zero. If realValue == 0 and intValue != 0, it is stored in the same variable, such that value() returns the value given as intValue.

Constructs a native gesture event of type type originating from device describing a gesture at scenePos in which fingerCount fingers are involved.

The points localPos, scenePos and globalPos specify the gesture position relative to the receiving widget or item, window, and screen or desktop, respectively.

value has a gesture-dependent interpretation: for RotateNativeGesture or SwipeNativeGesture, it’s an angle in degrees. For ZoomNativeGesture, value is an incremental scaling factor, usually much less than 1, indicating that the target item should have its scale adjusted like this: item.scale = item.scale * (1 + event.value)

For PanNativeGesture, delta gives the distance in pixels that the viewport, widget or item should be moved or panned.

Note

The delta is stored in single precision ( QVector2D ), so delta() may return slightly different values in some cases. This is subject to change in future versions of Qt.

PySide6.QtGui.QNativeGestureEvent.delta()
Return type

PySide6.QtCore.QPointF

Returns the distance moved since the previous event, in pixels. A Pan gesture provides the distance in pixels by which the target widget, item or viewport contents should be moved.

See also

delta()

PySide6.QtGui.QNativeGestureEvent.fingerCount()
Return type

int

Returns the number of fingers participating in the gesture, if known. When gestureType() is BeginNativeGesture or EndNativeGesture , often this information is unknown, and returns 0.

PySide6.QtGui.QNativeGestureEvent.gestureType()
Return type

NativeGestureType

Returns the gesture type.

PySide6.QtGui.QNativeGestureEvent.globalPos()
Return type

PySide6.QtCore.QPoint

Note

This function is deprecated.

Use globalPosition() .toPoint() instead.

Returns the position of the gesture as a QPointF in screen coordinates

PySide6.QtGui.QNativeGestureEvent.localPos()
Return type

PySide6.QtCore.QPointF

Note

This function is deprecated.

Use position() instead.

Returns the position of the gesture as a QPointF , relative to the widget or item that received the event.

PySide6.QtGui.QNativeGestureEvent.pos()
Return type

PySide6.QtCore.QPoint

Note

This function is deprecated.

Use position() .toPoint() instead.

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

PySide6.QtGui.QNativeGestureEvent.screenPos()
Return type

PySide6.QtCore.QPointF

Note

This function is deprecated.

Use globalPosition() instead.

Returns the position of the gesture as a QPointF in screen coordinates.

PySide6.QtGui.QNativeGestureEvent.value()
Return type

float

Returns the gesture value. The value should be interpreted based on the gesture type. For example, a Zoom gesture provides a scale factor delta while a Rotate gesture provides a rotation delta.

PySide6.QtGui.QNativeGestureEvent.windowPos()
Return type

PySide6.QtCore.QPointF

Note

This function is deprecated.

Use scenePosition() instead.

Returns the position of the gesture as a QPointF , relative to the window that received the event.