QGesture#

The QGesture class represents a gesture, containing properties that describe the corresponding user input. More

Inheritance diagram of PySide6.QtWidgets.QGesture

Inherited by: QTapGesture, QTapAndHoldGesture, QSwipeGesture, QPinchGesture, QPanGesture

New in version 4.6.

Synopsis#

Properties#

  • gestureCancelPolicy - The policy for deciding what happens on accepting a gesture

  • gestureType - The type of the gesture

  • hasHotSpot - Whether the gesture has a hot-spot

  • hotSpot - Point that is used to find the receiver for the gesture event

  • state - The current state of the gesture

Functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

Gesture objects are not constructed directly by developers. They are created by the QGestureRecognizer object that is registered with the application; see registerRecognizer() .

For an overview of gesture handling in Qt and information on using gestures in your applications, see the Gestures in Widgets and Graphics View document.

Gesture Properties#

The class has a list of properties that can be queried by the user to get some gesture-specific arguments. For example, the pinch gesture has a scale factor that is exposed as a property.

Developers of custom gesture recognizers can add additional properties in order to provide additional information about a gesture. This can be done by adding new dynamic properties to a QGesture object, or by subclassing the QGesture class (or one of its subclasses).

Lifecycle of a Gesture Object#

A QGesture instance is implicitly created when needed and is owned by Qt. Developers should never destroy them or store them for later use as Qt may destroy particular instances of them and create new ones to replace them.

The registered gesture recognizer monitors the input events for the target object via its recognize() function, updating the properties of the gesture object as required.

The gesture object may be delivered to the target object in a QGestureEvent if the corresponding gesture is active or has just been canceled. Each event that is delivered contains a list of gesture objects, since support for more than one gesture may be enabled for the target object. Due to the way events are handled in Qt, gesture events may be filtered by other objects.

class PySide6.QtWidgets.QGesture([parent=None])#
Parameters:

parentPySide6.QtCore.QObject

Constructs a new gesture object with the given parent.

QGesture objects are created by gesture recognizers in the create() function.

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property PᅟySide6.QtWidgets.QGesture.gestureCancelPolicy: GestureCancelPolicy#

This property holds the policy for deciding what happens on accepting a gesture.

On accepting one gesture Qt can automatically cancel other gestures that belong to other targets. The policy is normally set to not cancel any other gestures and can be set to cancel all active gestures in the context. For example for all child widgets.

Access functions:
property PᅟySide6.QtWidgets.QGesture.gestureType: GestureType#

This property holds the type of the gesture.

Access functions:
property PᅟySide6.QtWidgets.QGesture.hasHotSpot: bool#

This property holds whether the gesture has a hot-spot.

Access functions:
property PᅟySide6.QtWidgets.QGesture.hotSpot: PySide6.QtCore.QPointF#

This property holds The point that is used to find the receiver for the gesture event..

The hot-spot is a point in the global coordinate system, use mapFromGlobal() or mapToGraphicsScene() to get a local hot-spot.

The hot-spot should be set by the gesture recognizer to allow gesture event delivery to a QGraphicsObject .

Access functions:
property PᅟySide6.QtWidgets.QGesture.state: GestureState#

This property holds the current state of the gesture.

Access functions:
PySide6.QtWidgets.QGesture.GestureCancelPolicy#

This enum describes how accepting a gesture can cancel other gestures automatically.

Constant

Description

QGesture.CancelNone

On accepting this gesture no other gestures will be affected.

QGesture.CancelAllInContext

On accepting this gesture all gestures that are active in the context (respecting the Qt::GestureFlag that were specified when subscribed to the gesture) will be cancelled.

PySide6.QtWidgets.QGesture.gestureCancelPolicy()#
Return type:

GestureCancelPolicy

Getter of property gestureCancelPolicy .

PySide6.QtWidgets.QGesture.gestureType()#
Return type:

GestureType

Getter of property gestureType .

PySide6.QtWidgets.QGesture.hasHotSpot()#
Return type:

bool

Getter of property hasHotSpot .

PySide6.QtWidgets.QGesture.hotSpot()#
Return type:

PySide6.QtCore.QPointF

See also

setHotSpot()

Getter of property hotSpot .

PySide6.QtWidgets.QGesture.setGestureCancelPolicy(policy)#
Parameters:

policyGestureCancelPolicy

Setter of property gestureCancelPolicy .

PySide6.QtWidgets.QGesture.setHotSpot(value)#
Parameters:

valuePySide6.QtCore.QPointF

See also

hotSpot()

Setter of property hotSpot .

PySide6.QtWidgets.QGesture.state()#
Return type:

GestureState

Getter of property state .

PySide6.QtWidgets.QGesture.unsetHotSpot()#

Reset function of property hotSpot .