Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QQuickPointerHandler Class Reference

#include <qquickpointerhandler_p.h>

+ Inheritance diagram for QQuickPointerHandler:
+ Collaboration diagram for QQuickPointerHandler:

Public Types

enum  GrabPermission {
  TakeOverForbidden = 0x0 , CanTakeOverFromHandlersOfSameType = 0x01 , CanTakeOverFromHandlersOfDifferentType = 0x02 , CanTakeOverFromItems = 0x04 ,
  CanTakeOverFromAnything = 0x0F , ApprovesTakeOverByHandlersOfSameType = 0x10 , ApprovesTakeOverByHandlersOfDifferentType = 0x20 , ApprovesTakeOverByItems = 0x40 ,
  ApprovesCancellation = 0x80 , ApprovesTakeOverByAnything = 0xF0
}
 

Signals

void enabledChanged ()
 
void activeChanged ()
 
void targetChanged ()
 
void marginChanged ()
 
 Q_REVISION (2, 15) void dragThresholdChanged()
 
void grabChanged (QPointingDevice::GrabTransition transition, QEventPoint point)
 
void grabPermissionChanged ()
 
void canceled (QEventPoint point)
 
 Q_REVISION (6, 3) void parentChanged()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QQuickPointerHandler (QQuickItem *parent=nullptr)
 \qmltype PointerHandler \qmlabstract
 
 ~QQuickPointerHandler ()
 
bool enabled () const
 \qmlproperty bool QtQuick::PointerHandler::enabled
 
void setEnabled (bool enabled)
 
bool active () const
 \readonly \qmlproperty bool QtQuick::PointerHandler::active
 
QQuickItemtarget () const
 \qmlproperty Item QtQuick::PointerHandler::target
 
void setTarget (QQuickItem *target)
 
QQuickItemparentItem () const
 \qmlproperty Item QtQuick::PointerHandler::parent
 
void setParentItem (QQuickItem *p)
 
void handlePointerEvent (QPointerEvent *event)
 
GrabPermissions grabPermissions () const
 \qmlproperty flags QtQuick::PointerHandler::grabPermissions
 
void setGrabPermissions (GrabPermissions grabPermissions)
 
qreal margin () const
 \qmlproperty real PointerHandler::margin
 
void setMargin (qreal pointDistanceThreshold)
 
int dragThreshold () const
 \qmlproperty int PointerHandler::dragThreshold
 
void setDragThreshold (int t)
 
void resetDragThreshold ()
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 
- Public Member Functions inherited from QQmlParserStatus
 QQmlParserStatus ()
 
virtual ~QQmlParserStatus ()
 

Protected Member Functions

 QQuickPointerHandler (QQuickPointerHandlerPrivate &dd, QQuickItem *parent)
 
void classBegin () override
 Overridden only because QQmlParserStatus requires it.
 
void componentComplete () override
 Overridden from QQmlParserStatus to ensure that parentItem() sets its cursor if this handler's \l cursorShape property has been set.
 
bool event (QEvent *) override
 
QPointerEventcurrentEvent ()
 
virtual bool wantsPointerEvent (QPointerEvent *event)
 It is the responsibility of this function to decide whether the event could be relevant at all to this handler, as a preliminary check.
 
virtual bool wantsEventPoint (const QPointerEvent *event, const QEventPoint &point)
 Returns true if the given point (as part of event) could be relevant at all to this handler, as a preliminary check.
 
virtual void handlePointerEventImpl (QPointerEvent *event)
 This function can be overridden to implement whatever behavior a specific subclass is intended to have: \list.
 
void setActive (bool active)
 
virtual void onTargetChanged (QQuickItem *oldTarget)
 
virtual void onActiveChanged ()
 
virtual void onGrabChanged (QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, QPointerEvent *event, QEventPoint &point)
 Notification that the grab has changed in some way which is relevant to this handler.
 
virtual bool canGrab (QPointerEvent *event, const QEventPoint &point)
 Check whether it's OK to take an exclusive grab of the point.
 
virtual bool approveGrabTransition (QPointerEvent *event, const QEventPoint &point, QObject *proposedGrabber)
 Check this handler's rules to see if \l proposedGrabber will be allowed to take the exclusive grab.
 
void setPassiveGrab (QPointerEvent *event, const QEventPoint &point, bool grab=true)
 Acquire or give up a passive grab of the given point, according to the grab state.
 
bool setExclusiveGrab (QPointerEvent *ev, const QEventPoint &point, bool grab=true)
 Acquire or give up the exclusive grab of the given point, according to the grab state, and subject to the rules: canGrab(), and the rule not to relinquish another handler's grab.
 
void cancelAllGrabs (QPointerEvent *event, QEventPoint &point)
 Cancel any existing grab of the given point.
 
QPointF eventPos (const QEventPoint &point) const
 
bool parentContains (const QEventPoint &point) const
 Returns true if margin() > 0 and point is within the margin beyond QQuickItem::boundingRect(), or else returns QQuickItem::contains() QEventPoint::position() effectively (because parentContains(scenePosition) calls QQuickItem::mapFromScene()).
 
bool parentContains (const QPointF &scenePosition) const
 Returns true if scenePosition is within the margin() beyond QQuickItem::boundingRect() (if margin > 0), or parentItem() contains scenePosition according to QQuickItem::contains().
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Properties

bool enabled
 
bool active
 
QQuickItemtarget
 
QQuickItemparent
 
GrabPermissions grabPermissions
 
qreal margin
 
int dragThreshold
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Friends

class QQuickDeliveryAgentPrivate
 
class QQuickItemPrivate
 
class QQuickWindowPrivate
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

Definition at line 36 of file qquickpointerhandler_p.h.

Member Enumeration Documentation

◆ GrabPermission

Enumerator
TakeOverForbidden 
CanTakeOverFromHandlersOfSameType 
CanTakeOverFromHandlersOfDifferentType 
CanTakeOverFromItems 
CanTakeOverFromAnything 
ApprovesTakeOverByHandlersOfSameType 
ApprovesTakeOverByHandlersOfDifferentType 
ApprovesTakeOverByItems 
ApprovesCancellation 
ApprovesTakeOverByAnything 

Definition at line 61 of file qquickpointerhandler_p.h.

Constructor & Destructor Documentation

◆ QQuickPointerHandler() [1/2]

QT_BEGIN_NAMESPACE QQuickPointerHandler::QQuickPointerHandler ( QQuickItem * parent = nullptr)
explicit

\qmltype PointerHandler \qmlabstract

Since
5.10 \instantiates QQuickPointerHandler \inqmlmodule QtQuick

Abstract handler for pointer events.

PointerHandler is the base class Input Handler (not registered as a QML type) for events from any kind of pointing device (touch, mouse or graphics tablet).

So far we only offer public QML API for Pointer Handlers, but we expect in some future version of Qt to have public C++ API as well. This will open up the possibility to instantiate handlers in custom items (which we should begin doing in Qt Quick Controls in the near future), and to subclass to make custom handlers (as TableView is already doing).

To make a custom Pointer Handler, first try to choose the parent class according to your needs. If the gesture that you want to recognize could involve multiple touchpoints (even if it could start with only one point), subclass QQuickMultiPointHandler. If you are sure that you never want to handle more than one QEventPoint, subclass QQuickSinglePointHandler.

Definition at line 45 of file qquickpointerhandler.cpp.

◆ ~QQuickPointerHandler()

QQuickPointerHandler::~QQuickPointerHandler ( )

Definition at line 62 of file qquickpointerhandler.cpp.

References QQuickItemPrivate::get(), and parentItem().

+ Here is the call graph for this function:

◆ QQuickPointerHandler() [2/2]

QQuickPointerHandler::QQuickPointerHandler ( QQuickPointerHandlerPrivate & dd,
QQuickItem * parent )
protected

Definition at line 50 of file qquickpointerhandler.cpp.

References QQuickItemPrivate::get(), and parent.

+ Here is the call graph for this function:

Member Function Documentation

◆ active()

bool QQuickPointerHandler::active ( ) const

\readonly \qmlproperty bool QtQuick::PointerHandler::active

This holds true whenever this Input Handler has taken sole responsibility for handing one or more \l {eventPoint}{eventPoints}, by successfully taking an exclusive grab of those points. This means that it is keeping its properties up-to-date according to the movements of those eventPoints and actively manipulating its \l target (if any).

Definition at line 805 of file qquickpointerhandler.cpp.

References d.

◆ activeChanged

void QQuickPointerHandler::activeChanged ( )
signal

Referenced by QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate(), QQuickSelectionRectanglePrivate::createHandle(), and setActive().

+ Here is the caller graph for this function:

◆ approveGrabTransition()

bool QQuickPointerHandler::approveGrabTransition ( QPointerEvent * event,
const QEventPoint & point,
QObject * proposedGrabber )
protectedvirtual

Check this handler's rules to see if \l proposedGrabber will be allowed to take the exclusive grab.

This function may be called twice: once on the instance which will take the grab, and once on the instance which would thereby lose its grab, in case of a takeover scenario.

Definition at line 331 of file qquickpointerhandler.cpp.

References ApprovesCancellation, ApprovesTakeOverByAnything, ApprovesTakeOverByHandlersOfDifferentType, ApprovesTakeOverByHandlersOfSameType, ApprovesTakeOverByItems, CanTakeOverFromAnything, CanTakeOverFromHandlersOfDifferentType, CanTakeOverFromHandlersOfSameType, CanTakeOverFromItems, className, QQuickDeliveryAgentPrivate::currentEventDeliveryAgent, d, QObjectPrivate::get(), QQuickItemPrivate::get(), grabPermissions, Qt::hex(), QEventPoint::id, QQuickDeliveryAgentPrivate::isMouseEvent(), QQuickDeliveryAgentPrivate::isTouchEvent(), metaObject(), parentItem(), Q_ASSERT, qCDebug, and qobject_cast< QQuickItem * >().

Referenced by canGrab().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelAllGrabs()

void QQuickPointerHandler::cancelAllGrabs ( QPointerEvent * event,
QEventPoint & point )
protected

Cancel any existing grab of the given point.

Definition at line 524 of file qquickpointerhandler.cpp.

References QPointingDevice::CancelGrabExclusive, QPointingDevice::CancelGrabPassive, onGrabChanged(), and qCDebug.

Referenced by QQuickSinglePointHandler::wantsPointerEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ canceled

void QQuickPointerHandler::canceled ( QEventPoint point)
signal

Referenced by onGrabChanged().

+ Here is the caller graph for this function:

◆ canGrab()

bool QQuickPointerHandler::canGrab ( QPointerEvent * event,
const QEventPoint & point )
protectedvirtual

Check whether it's OK to take an exclusive grab of the point.

The default implementation will call approveGrabTransition() to check this handler's \l grabPermissions. If grabbing can be done only by taking over the exclusive grab from an Item, approveGrabTransition() checks the Item's \l keepMouseGrab or \l keepTouchGrab flags appropriately. If grabbing can be done only by taking over another handler's exclusive grab, canGrab() also calls approveGrabTransition() on the handler which is about to lose its grab. Either one can deny the takeover.

Definition at line 318 of file qquickpointerhandler.cpp.

References approveGrabTransition().

Referenced by QQuickMultiPointHandler::eligiblePoints(), QQuickMultiPointHandler::grabPoints(), and setExclusiveGrab().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ classBegin()

void QQuickPointerHandler::classBegin ( )
overrideprotectedvirtual

Overridden only because QQmlParserStatus requires it.

Implements QQmlParserStatus.

Definition at line 460 of file qquickpointerhandler.cpp.

◆ componentComplete()

void QQuickPointerHandler::componentComplete ( )
overrideprotectedvirtual

Overridden from QQmlParserStatus to ensure that parentItem() sets its cursor if this handler's \l cursorShape property has been set.

Implements QQmlParserStatus.

Definition at line 468 of file qquickpointerhandler.cpp.

References d, QQuickItemPrivate::get(), parent, and parentItem().

+ Here is the call graph for this function:

◆ currentEvent()

QPointerEvent * QQuickPointerHandler::currentEvent ( )
protected
Deprecated
You should handle the event during delivery by overriding handlePointerEventImpl() or QQuickSinglePointHandler::handleEventPoint(). Therefore currentEvent() should not be needed. It is here only because onActiveChanged() does not take the event as an argument.

Definition at line 486 of file qquickpointerhandler.cpp.

References d.

Referenced by QQuickDragHandler::onActiveChanged().

+ Here is the caller graph for this function:

◆ dragThreshold()

int QQuickPointerHandler::dragThreshold ( ) const

\qmlproperty int PointerHandler::dragThreshold

Since
5.15

The distance in pixels that the user must drag an \l eventPoint in order to have it treated as a drag gesture.

The default value depends on the platform and screen resolution. It can be reset back to the default value by setting it to undefined. The behavior when a drag gesture begins varies in different handlers.

Definition at line 115 of file qquickpointerhandler.cpp.

References d, and qApp.

◆ enabled()

bool QQuickPointerHandler::enabled ( ) const

\qmlproperty bool QtQuick::PointerHandler::enabled

If a PointerHandler is disabled, it will reject all events and no signals will be emitted.

Definition at line 589 of file qquickpointerhandler.cpp.

References d.

◆ enabledChanged

void QQuickPointerHandler::enabledChanged ( )
signal

Referenced by setEnabled().

+ Here is the caller graph for this function:

◆ event()

bool QQuickPointerHandler::event ( QEvent * e)
overrideprotectedvirtual

Pointer Handlers do most of their work in implementations of virtual functions that are called directly from QQuickItem, not by direct event handling. But it's convenient to deliver TouchCancel events via QCoreApplication::sendEvent(). Perhaps it will turn out that more events could be delivered this way.

Reimplemented from QObject.

Definition at line 688 of file qquickpointerhandler.cpp.

References QPointingDevice::CancelGrabExclusive, QObject::event(), i, onGrabChanged(), QEvent::TouchCancel, and QEvent::type().

+ Here is the call graph for this function:

◆ eventPos()

QPointF QQuickPointerHandler::eventPos ( const QEventPoint & point) const
protected

Definition at line 535 of file qquickpointerhandler.cpp.

References QEventPoint::scenePosition, and target.

◆ grabChanged

◆ grabPermissionChanged

void QQuickPointerHandler::grabPermissionChanged ( )
signal

Referenced by setGrabPermissions().

+ Here is the caller graph for this function:

◆ grabPermissions()

QQuickPointerHandler::GrabPermissions QQuickPointerHandler::grabPermissions ( ) const

\qmlproperty flags QtQuick::PointerHandler::grabPermissions

This property specifies the permissions when this handler's logic decides to take over the exclusive grab, or when it is asked to approve grab takeover or cancellation by another handler.

\value PointerHandler.TakeOverForbidden This handler neither takes from nor gives grab permission to any type of Item or Handler. \value PointerHandler.CanTakeOverFromHandlersOfSameType This handler can take the exclusive grab from another handler of the same class. \value PointerHandler.CanTakeOverFromHandlersOfDifferentType This handler can take the exclusive grab from any kind of handler. \value PointerHandler.CanTakeOverFromItems This handler can take the exclusive grab from any type of Item. \value PointerHandler.CanTakeOverFromAnything This handler can take the exclusive grab from any type of Item or Handler. \value PointerHandler.ApprovesTakeOverByHandlersOfSameType This handler gives permission for another handler of the same class to take the grab. \value PointerHandler.ApprovesTakeOverByHandlersOfDifferentType This handler gives permission for any kind of handler to take the grab. \value PointerHandler.ApprovesTakeOverByItems This handler gives permission for any kind of Item to take the grab. \value PointerHandler.ApprovesCancellation This handler will allow its grab to be set to null. \value PointerHandler.ApprovesTakeOverByAnything This handler gives permission for any type of Item or Handler to take the grab.

The default is {PointerHandler.CanTakeOverFromItems | PointerHandler.CanTakeOverFromHandlersOfDifferentType | PointerHandler.ApprovesTakeOverByAnything} which allows most takeover scenarios but avoids e.g. two PinchHandlers fighting over the same touchpoints.

Definition at line 441 of file qquickpointerhandler.cpp.

References d.

◆ handlePointerEvent()

void QQuickPointerHandler::handlePointerEvent ( QPointerEvent * event)

The entry point to handle the event: it's called from QQuickItemPrivate::handlePointerEvent(), begins with wantsPointerEvent(), and calls handlePointerEventImpl() if that returns true.

Definition at line 709 of file qquickpointerhandler.cpp.

References d, QQuickPointerHandlerPrivate::deviceDeliveryTargets(), handlePointerEventImpl(), i, metaObject(), QEvent::NativeGesture, QObject::objectName, parent, qCDebug, setActive(), QEventPoint::Stationary, and wantsPointerEvent().

Referenced by QQuickDeliveryAgentPrivate::deliverUpdatedPoints().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlePointerEventImpl()

void QQuickPointerHandler::handlePointerEventImpl ( QPointerEvent * event)
protectedvirtual

This function can be overridden to implement whatever behavior a specific subclass is intended to have: \list.

Reimplemented in QQuickDragHandler, QQuickMultiPointHandler, QQuickPinchHandler, and QQuickSinglePointHandler.

Definition at line 834 of file qquickpointerhandler.cpp.

References Q_UNUSED.

Referenced by handlePointerEvent(), QQuickMultiPointHandler::handlePointerEventImpl(), and QQuickSinglePointHandler::handlePointerEventImpl().

+ Here is the caller graph for this function:

◆ margin()

qreal QQuickPointerHandler::margin ( ) const

\qmlproperty real PointerHandler::margin

The margin beyond the bounds of the \l {PointerHandler::parent}{parent} item within which an \l eventPoint can activate this handler. For example, on a PinchHandler where the \l {PointerHandler::target}{target} is also the parent, it's useful to set this to a distance at least half the width of a typical user's finger, so that if the parent has been scaled down to a very small size, the pinch gesture is still possible. Or, if a TapHandler-based button is placed near the screen edge, it can be used to comply with Fitts's Law: react to mouse clicks at the screen edge even though the button is visually spaced away from the edge by a few pixels.

The default value is 0.

Definition at line 88 of file qquickpointerhandler.cpp.

References d.

◆ marginChanged

void QQuickPointerHandler::marginChanged ( )
signal

Referenced by setMargin().

+ Here is the caller graph for this function:

◆ onActiveChanged()

virtual void QQuickPointerHandler::onActiveChanged ( )
inlineprotectedvirtual

Reimplemented in QQuickDragHandler, QQuickMultiPointHandler, QQuickPinchHandler, and QQuickWheelHandler.

Definition at line 134 of file qquickpointerhandler_p.h.

Referenced by setActive().

+ Here is the caller graph for this function:

◆ onGrabChanged()

void QQuickPointerHandler::onGrabChanged ( QQuickPointerHandler * grabber,
QPointingDevice::GrabTransition transition,
QPointerEvent * event,
QEventPoint & point )
protectedvirtual

Notification that the grab has changed in some way which is relevant to this handler.

Since
5.15 \qmlproperty Qt::CursorShape PointerHandler::cursorShape This property holds the cursor shape that will appear whenever the mouse is hovering over the \l parent item while \l active is true.

The available cursor shapes are: \list

The default value is not set, which allows the \l {QQuickItem::cursor()}{cursor} of \l parent item to appear. This property can be reset to the same initial condition by setting it to undefined.

Note
When this property has not been set, or has been set to undefined, if you read the value it will return Qt.ArrowCursor.
See also
Qt::CursorShape, QQuickItem::cursor(), HoverHandler::cursorShape

The grabber (subject) will be the Input Handler whose state is changing, or null if the state change regards an Item. The transition (verb) tells what happened. The point (object) is the \l eventPoint that was grabbed or ungrabbed. QQuickDeliveryAgent calls this function. The Input Handler must react in whatever way is appropriate, and must emit the relevant signals (for the benefit of QML code). A subclass is allowed to override this virtual function, but must always call its parent class's implementation in addition to (usually after) whatever custom behavior it implements.

Reimplemented in QQuickTapHandler, QQuickTableViewResizeHandler, QQuickDragHandler, QQuickMultiPointHandler, and QQuickSinglePointHandler.

Definition at line 245 of file qquickpointerhandler.cpp.

References canceled(), QPointingDevice::CancelGrabExclusive, QPointingDevice::CancelGrabPassive, d, emit, grabChanged(), QPointingDevice::GrabExclusive, QPointingDevice::GrabPassive, QPointingDevice::OverrideGrabPassive, parentItem(), Q_FALLTHROUGH, Q_UNUSED, qCDebug, QEventPoint::setAccepted(), setActive(), QPointingDevice::UngrabExclusive, and QPointingDevice::UngrabPassive.

Referenced by cancelAllGrabs(), event(), QQuickMultiPointHandler::onGrabChanged(), and QQuickSinglePointHandler::onGrabChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onTargetChanged()

virtual void QQuickPointerHandler::onTargetChanged ( QQuickItem * oldTarget)
inlineprotectedvirtual

Reimplemented in QQuickWheelHandler.

Definition at line 133 of file qquickpointerhandler_p.h.

References Q_UNUSED.

Referenced by setTarget().

+ Here is the caller graph for this function:

◆ parentContains() [1/2]

bool QQuickPointerHandler::parentContains ( const QEventPoint & point) const
protected

Returns true if margin() > 0 and point is within the margin beyond QQuickItem::boundingRect(), or else returns QQuickItem::contains() QEventPoint::position() effectively (because parentContains(scenePosition) calls QQuickItem::mapFromScene()).

Definition at line 546 of file qquickpointerhandler.cpp.

References parentContains(), and QEventPoint::scenePosition.

Referenced by parentContains(), wantsEventPoint(), QQuickTapHandler::wantsEventPoint(), QQuickHoverHandler::wantsPointerEvent(), QQuickPinchHandler::wantsPointerEvent(), and QQuickWheelHandler::wantsPointerEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parentContains() [2/2]

bool QQuickPointerHandler::parentContains ( const QPointF & scenePosition) const
protected

Returns true if scenePosition is within the margin() beyond QQuickItem::boundingRect() (if margin > 0), or parentItem() contains scenePosition according to QQuickItem::contains().

(So if the \l margin property is set, that overrides the bounds-check, and QQuickItem::contains() is not called.) As a precheck, it's also required that the window contains scenePosition mapped to global coordinates, if parentItem() is in a window.

Definition at line 559 of file qquickpointerhandler.cpp.

References QRectF::contains(), QWindowPrivate::get(), QObject::inherits(), margin, parent, and parentItem().

+ Here is the call graph for this function:

◆ parentItem()

QQuickItem * QQuickPointerHandler::parentItem ( ) const

\qmlproperty Item QtQuick::PointerHandler::parent

The \l Item which is the scope of the handler; the Item in which it was declared. The handler will handle events on behalf of this Item, which means a pointer event is relevant if at least one of its \l {eventPoint}{eventPoints} occurs within the Item's interior. Initially \l [QML] {target} {target()} is the same, but it can be reassigned.

See also
{target}, QObject::parent()

We still haven't shipped official support for declaring handlers in QtQuick3D.Model objects. Many prerequisites are in place for that, so we should try to keep it working; but there are issues with getting DragHandler to drag its target intuitively in 3D space, for example. TapHandler would work well enough.

Note
When a handler is declared in a \l [QtQuick3D] {Model}{QtQuick3D.Model} object, the parent is not an Item, therefore this property is null.

Definition at line 660 of file qquickpointerhandler.cpp.

References QObject::parent(), and qmlobject_cast< QQuickItem * >().

Referenced by QQuickTableViewHoverHandler::QQuickTableViewHoverHandler(), QQuickHoverHandler::~QQuickHoverHandler(), ~QQuickPointerHandler(), approveGrabTransition(), QQuickHoverHandler::componentComplete(), componentComplete(), QQuickTableViewHoverHandler::handleEventPoint(), QQuickDragHandler::handlePointerEventImpl(), QQuickPinchHandler::handlePointerEventImpl(), QQuickItemPrivate::localizedTouchEvent(), QQuickDragHandler::onActiveChanged(), onGrabChanged(), QQuickDragHandler::onGrabChanged(), parentContains(), setPassiveGrab(), target(), QQuickTableViewResizeHandler::updateDrag(), QQuickTableViewResizeHandler::updateState(), QQuickTableViewResizeHandler::wantsEventPoint(), QQuickTableViewTapHandler::wantsEventPoint(), and QQuickMultiPointHandler::wantsPointerEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Q_REVISION [1/2]

QQuickPointerHandler::Q_REVISION ( 2 ,
15  )
signal

◆ Q_REVISION [2/2]

QQuickPointerHandler::Q_REVISION ( 6 ,
3  )
signal

◆ resetDragThreshold()

void QQuickPointerHandler::resetDragThreshold ( )

Definition at line 135 of file qquickpointerhandler.cpp.

References d, and emit.

◆ setActive()

void QQuickPointerHandler::setActive ( bool active)
protected

Definition at line 811 of file qquickpointerhandler.cpp.

References active, activeChanged(), d, emit, onActiveChanged(), and qCDebug.

Referenced by QQuickHoverHandler::event(), QQuickPointHandler::handleEventPoint(), QQuickWheelHandler::handleEventPoint(), handlePointerEvent(), QQuickDragHandler::handlePointerEventImpl(), QQuickPinchHandler::handlePointerEventImpl(), onGrabChanged(), QQuickSinglePointHandler::onGrabChanged(), QQuickWheelHandler::timerEvent(), and QQuickMultiPointHandler::wantsPointerEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDragThreshold()

void QQuickPointerHandler::setDragThreshold ( int t)

Definition at line 123 of file qquickpointerhandler.cpp.

References d, emit, and qWarning.

◆ setEnabled()

void QQuickPointerHandler::setEnabled ( bool enabled)

Definition at line 595 of file qquickpointerhandler.cpp.

References d, emit, enabled, and enabledChanged().

Referenced by QQuickTableViewPrivate::init(), and QQuickSelectionRectanglePrivate::updateSelectionMode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setExclusiveGrab()

bool QQuickPointerHandler::setExclusiveGrab ( QPointerEvent * ev,
const QEventPoint & point,
bool grab = true )
protected

Acquire or give up the exclusive grab of the given point, according to the grab state, and subject to the rules: canGrab(), and the rule not to relinquish another handler's grab.

Returns true if permission is granted, or if the exclusive grab has already been acquired or relinquished as specified. Returns false if permission is denied either by this handler or by the handler or item from which this handler would take over

Definition at line 500 of file qquickpointerhandler.cpp.

References canGrab(), qCDebug, and this.

Referenced by QQuickMultiPointHandler::grabPoints(), QQuickSinglePointHandler::handleEventPoint(), and QQuickTableViewResizeHandler::updateDrag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGrabPermissions()

void QQuickPointerHandler::setGrabPermissions ( GrabPermissions grabPermissions)

Definition at line 447 of file qquickpointerhandler.cpp.

References d, emit, and grabPermissionChanged().

Referenced by QQuickTableViewResizeHandler::QQuickTableViewResizeHandler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMargin()

void QQuickPointerHandler::setMargin ( qreal pointDistanceThreshold)

Definition at line 94 of file qquickpointerhandler.cpp.

References d, emit, and marginChanged().

Referenced by QQuickTableViewHoverHandler::QQuickTableViewHoverHandler(), and QQuickTableViewResizeHandler::QQuickTableViewResizeHandler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setParentItem()

void QQuickPointerHandler::setParentItem ( QQuickItem * p)

Definition at line 665 of file qquickpointerhandler.cpp.

References d, emit, QQuickItemPrivate::get(), QObject::parent(), parent, qCDebug, and QObject::setParent().

Referenced by QQuickSelectionRectanglePrivate::createHandle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPassiveGrab()

void QQuickPointerHandler::setPassiveGrab ( QPointerEvent * event,
const QEventPoint & point,
bool grab = true )
protected

Acquire or give up a passive grab of the given point, according to the grab state.

Unlike the exclusive grab, multiple Input Handlers can have passive grabs simultaneously. This means that each of them will receive further events when the point moves, and when it is finally released. Typically an Input Handler should acquire a passive grab as soon as a point is pressed, if the handler's constraints do not clearly rule out any interest in that point. For example, DragHandler needs a passive grab in order to watch the movement of a point to see whether it will be dragged past the drag threshold. When a handler is actively manipulating its \l target (that is, when \l active is true), it may be able to do its work with only a passive grab, or it may acquire an exclusive grab if the gesture clearly must not be interpreted in another way by another handler.

Definition at line 296 of file qquickpointerhandler.cpp.

References QQuickDeliveryAgentPrivate::currentOrItemDeliveryAgent(), parentItem(), and qCDebug.

Referenced by QQuickPointHandler::handleEventPoint(), QQuickDragHandler::handlePointerEventImpl(), QQuickPinchHandler::handlePointerEventImpl(), and QQuickTableViewResizeHandler::updateDrag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTarget()

void QQuickPointerHandler::setTarget ( QQuickItem * target)

Definition at line 626 of file qquickpointerhandler.cpp.

References d, emit, onTargetChanged(), target, and targetChanged().

Referenced by QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate(), and QQuickSelectionRectanglePrivate::createHandle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ target()

QQuickItem * QQuickPointerHandler::target ( ) const

\qmlproperty Item QtQuick::PointerHandler::target

The Item which this handler will manipulate.

By default, it is the same as the \l [QML] {parent}, the Item within which the handler is declared. However, it can sometimes be useful to set the target to a different Item, in order to handle events within one item but manipulate another; or to null, to disable the default behavior and do something else instead.

Definition at line 618 of file qquickpointerhandler.cpp.

References d, and parentItem().

+ Here is the call graph for this function:

◆ targetChanged

void QQuickPointerHandler::targetChanged ( )
signal

Referenced by setTarget().

+ Here is the caller graph for this function:

◆ wantsEventPoint()

bool QQuickPointerHandler::wantsEventPoint ( const QPointerEvent * event,
const QEventPoint & point )
protectedvirtual

Returns true if the given point (as part of event) could be relevant at all to this handler, as a preliminary check.

If you override this function, you should call the immediate parent class implementation (and return false if it returns false); that in turn calls its parent class implementation, and so on.

In particular, the bounds checking is done here: the base class QQuickPointerHandler::wantsEventPoint() calls parentContains(point) (which allows the flexibility promised by margin(), QQuickItem::contains() and QQuickItem::containmentMask()). Pointer Handlers can receive QEventPoints that are outside the parent item's bounds: this allows some flexibility for dealing with multi-point gestures in which one or more fingers have strayed outside the bounds, and yet the gesture is still unambiguously intended for the target() item.

You should not generally react to the event or point here, but it's ok to set state to remember what needs to be done in your overridden handlePointerEventImpl() or QQuickSinglePointHandler::handleEventPoint().

Reimplemented in QQuickPointHandler, QQuickTapHandler, QQuickTableViewResizeHandler, and QQuickTableViewTapHandler.

Definition at line 785 of file qquickpointerhandler.cpp.

References Qt::hex(), QEventPoint::id, metaObject(), QObject::objectName, parentContains(), Q_UNUSED, qCDebug, ret, and QEventPoint::scenePosition.

Referenced by QQuickMultiPointHandler::eligiblePoints(), QQuickPointHandler::wantsEventPoint(), QQuickTableViewResizeHandler::wantsEventPoint(), QQuickHoverHandler::wantsPointerEvent(), QQuickSinglePointHandler::wantsPointerEvent(), and QQuickWheelHandler::wantsPointerEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wantsPointerEvent()

bool QQuickPointerHandler::wantsPointerEvent ( QPointerEvent * event)
protectedvirtual

It is the responsibility of this function to decide whether the event could be relevant at all to this handler, as a preliminary check.

Returns true if this handler would like handlePointerEventImpl() to be called. If it returns false, the handler will be deactivated: setActive(false) will be called, and any remaining exclusive grab will be relinquished, as a fail-safe.

If you override this function, you should call the immediate parent class implementation (and return false if it returns false); that in turn calls its parent class implementation, and so on. QQuickSinglePointHandler::wantsPointerEvent() and QQuickMultiPointHandler::wantsPointerEvent() call wantsEventPoint(), which is also virtual. You usually can get the behavior you want by subclassing the appropriate handler type, overriding QQuickSinglePointHandler::handleEventPoint() or handlePointerEventImpl(), and perhaps overriding wantsEventPoint() if needed.

See also
wantsEventPoint(), QQuickPointerDeviceHandler::wantsPointerEvent(), QQuickMultiPointHandler::wantsPointerEvent(), QQuickSinglePointHandler::wantsPointerEvent()

Reimplemented in QQuickDragHandler, QQuickHoverHandler, QQuickMultiPointHandler, QQuickPinchHandler, QQuickPointerDeviceHandler, QQuickSinglePointHandler, and QQuickWheelHandler.

Definition at line 757 of file qquickpointerhandler.cpp.

References d, and Q_UNUSED.

Referenced by handlePointerEvent(), and QQuickPointerDeviceHandler::wantsPointerEvent().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ QQuickDeliveryAgentPrivate

friend class QQuickDeliveryAgentPrivate
friend

Definition at line 146 of file qquickpointerhandler_p.h.

◆ QQuickItemPrivate

friend class QQuickItemPrivate
friend

Definition at line 147 of file qquickpointerhandler_p.h.

◆ QQuickWindowPrivate

friend class QQuickWindowPrivate
friend

Definition at line 148 of file qquickpointerhandler_p.h.

Property Documentation

◆ active

◆ dragThreshold

int QQuickPointerHandler::dragThreshold
readwrite

Definition at line 47 of file qquickpointerhandler_p.h.

Referenced by QQuickPinchHandler::handlePointerEventImpl().

◆ enabled

bool QQuickPointerHandler::enabled
readwrite

◆ grabPermissions

GrabPermissions QQuickPointerHandler::grabPermissions
readwrite

Definition at line 45 of file qquickpointerhandler_p.h.

Referenced by approveGrabTransition().

◆ margin

qreal QQuickPointerHandler::margin
readwrite

◆ parent

◆ target


The documentation for this class was generated from the following files: