![]() |
Qt 6.x
The Qt SDK
|
#include <qquickpointerhandler_p.h>
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() | |
![]() | |
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 | |
QQuickItem * | target () const |
\qmlproperty Item QtQuick::PointerHandler::target | |
void | setTarget (QQuickItem *target) |
QQuickItem * | parentItem () 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 () |
![]() | |
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 | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
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< QString > | bindableObjectName () |
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). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. | |
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::milliseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
template<typename T > | |
T | findChild (const QString &aName=QString(), 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 (const QString &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 > | |
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 QObjectList & | children () 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< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () 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 . | |
![]() | |
QQmlParserStatus () | |
virtual | ~QQmlParserStatus () |
virtual void | classBegin ()=0 |
Invoked after class creation, but before any properties have been set. | |
virtual void | componentComplete ()=0 |
Invoked after the root component that caused this instantiation has completed construction. | |
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 |
QPointerEvent * | currentEvent () |
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: | |
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(). | |
![]() | |
QObject * | sender () 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 |
QQuickItem * | target |
QQuickItem * | parent |
GrabPermissions | grabPermissions |
qreal | margin |
int | dragThreshold |
![]() | |
QString | objectName |
the name of this object | |
Friends | |
class | QQuickDeliveryAgentPrivate |
class | QQuickItemPrivate |
class | QQuickWindowPrivate |
Additional Inherited Members | |
![]() | |
void | deleteLater () |
\threadsafe | |
![]() | |
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) |
![]() | |
QScopedPointer< QObjectData > | d_ptr |
![]() | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) | |
Definition at line 36 of file qquickpointerhandler_p.h.
Definition at line 61 of file qquickpointerhandler_p.h.
|
explicit |
\qmltype PointerHandler \qmlabstract
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 43 of file qquickpointerhandler.cpp.
QQuickPointerHandler::~QQuickPointerHandler | ( | ) |
Definition at line 60 of file qquickpointerhandler.cpp.
References QQuickItemPrivate::get(), and parentItem().
|
protected |
Definition at line 48 of file qquickpointerhandler.cpp.
References QQuickItemPrivate::addPointerHandler(), QQuickItemPrivate::get(), and parent.
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 801 of file qquickpointerhandler.cpp.
References d.
|
signal |
Referenced by QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate(), QQuickSelectionRectanglePrivate::createHandle(), and setActive().
|
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 327 of file qquickpointerhandler.cpp.
References ApprovesCancellation, ApprovesTakeOverByAnything, ApprovesTakeOverByHandlersOfDifferentType, ApprovesTakeOverByHandlersOfSameType, ApprovesTakeOverByItems, CanTakeOverFromAnything, CanTakeOverFromHandlersOfDifferentType, CanTakeOverFromHandlersOfSameType, CanTakeOverFromItems, className, QQuickDeliveryAgentPrivate::currentEventDeliveryAgent, d, QQuickItemPrivate::deliveryAgentPrivate(), QQuickItem::filtersChildMouseEvents(), QObjectPrivate::get(), QQuickItemPrivate::get(), grabPermissions, Qt::hex(), QEventPoint::id, QObject::inherits(), QQuickItem::isAncestorOf(), QQuickDeliveryAgentPrivate::isMouseEvent(), QQuickDeliveryAgentPrivate::isTouchEvent(), QQuickItem::keepMouseGrab(), QQuickItem::keepTouchGrab(), metaObject(), parentItem(), Q_ASSERT, qCDebug, and qobject_cast< QQuickItem * >().
Referenced by canGrab(), and setExclusiveGrab().
|
protected |
Cancel any existing grab of the given point.
Definition at line 520 of file qquickpointerhandler.cpp.
References QPointingDevice::CancelGrabExclusive, QPointingDevice::CancelGrabPassive, onGrabChanged(), and qCDebug.
Referenced by QQuickSinglePointHandler::wantsPointerEvent().
|
signal |
|
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 314 of file qquickpointerhandler.cpp.
References approveGrabTransition().
Referenced by QQuickMultiPointHandler::eligiblePoints(), QQuickMultiPointHandler::grabPoints(), and setExclusiveGrab().
|
overrideprotectedvirtual |
Overridden only because QQmlParserStatus requires it.
Implements QQmlParserStatus.
Definition at line 456 of file qquickpointerhandler.cpp.
|
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 464 of file qquickpointerhandler.cpp.
References d, QQuickItemPrivate::get(), QQuickItemPrivate::hasCursorHandler, parent, parentItem(), and QQuickItemPrivate::setHasCursorInChild().
|
protected |
Definition at line 482 of file qquickpointerhandler.cpp.
References d.
Referenced by QQuickDragHandler::onActiveChanged().
int QQuickPointerHandler::dragThreshold | ( | ) | const |
\qmlproperty int PointerHandler::dragThreshold
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 113 of file qquickpointerhandler.cpp.
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 585 of file qquickpointerhandler.cpp.
References d.
|
signal |
|
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 684 of file qquickpointerhandler.cpp.
References QPointingDevice::CancelGrabExclusive, e, QObject::event(), i, onGrabChanged(), and QEvent::TouchCancel.
|
protected |
Definition at line 531 of file qquickpointerhandler.cpp.
References QEventPoint::scenePosition, and target.
|
signal |
Referenced by onGrabChanged(), QWaylandQtShellChrome::setBottomLeftResizeHandle(), QWaylandQtShellChrome::setBottomResizeHandle(), QWaylandQtShellChrome::setBottomRightResizeHandle(), QWaylandQtShellChrome::setLeftResizeHandle(), QWaylandQtShellChrome::setRightResizeHandle(), QWaylandQtShellChrome::setTitleBar(), QWaylandQtShellChrome::setTopLeftResizeHandle(), QWaylandQtShellChrome::setTopResizeHandle(), and QWaylandQtShellChrome::setTopRightResizeHandle().
|
signal |
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 437 of file qquickpointerhandler.cpp.
References d.
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 705 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().
|
protectedvirtual |
This function can be overridden to implement whatever behavior a specific subclass is intended to have:
true
Reimplemented in QQuickDragHandler, QQuickMultiPointHandler, QQuickPinchHandler, and QQuickSinglePointHandler.
Definition at line 827 of file qquickpointerhandler.cpp.
References Q_UNUSED.
Referenced by handlePointerEvent(), QQuickMultiPointHandler::handlePointerEventImpl(), and QQuickSinglePointHandler::handlePointerEventImpl().
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 86 of file qquickpointerhandler.cpp.
References d.
|
signal |
|
inlineprotectedvirtual |
Reimplemented in QQuickDragHandler, QQuickMultiPointHandler, QQuickPinchHandler, and QQuickWheelHandler.
Definition at line 134 of file qquickpointerhandler_p.h.
Referenced by setActive().
|
protectedvirtual |
Notification that the grab has changed in some way which is relevant to this handler.
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.
undefined
, if you read the value it will return Qt.ArrowCursor
.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 241 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().
|
inlineprotectedvirtual |
Reimplemented in QQuickWheelHandler.
Definition at line 133 of file qquickpointerhandler_p.h.
References Q_UNUSED.
Referenced by setTarget().
|
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 542 of file qquickpointerhandler.cpp.
References parentContains(), and QEventPoint::scenePosition.
Referenced by parentContains(), wantsEventPoint(), QQuickTapHandler::wantsEventPoint(), QQuickHoverHandler::wantsPointerEvent(), QQuickPinchHandler::wantsPointerEvent(), and QQuickWheelHandler::wantsPointerEvent().
|
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 555 of file qquickpointerhandler.cpp.
References QRect::contains(), QWindowPrivate::get(), QWindowPrivate::globalPosition(), QObject::inherits(), margin, parent, parentItem(), and QPointF::toPoint().
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.
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.
null
. Definition at line 656 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().
|
signal |
|
signal |
void QQuickPointerHandler::resetDragThreshold | ( | ) |
Definition at line 133 of file qquickpointerhandler.cpp.
|
protected |
Definition at line 807 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().
void QQuickPointerHandler::setDragThreshold | ( | int | t | ) |
Definition at line 121 of file qquickpointerhandler.cpp.
void QQuickPointerHandler::setEnabled | ( | bool | enabled | ) |
Definition at line 591 of file qquickpointerhandler.cpp.
References d, emit, enabled, and enabledChanged().
Referenced by QQuickTableViewPrivate::init(), and QQuickSelectionRectanglePrivate::updateSelectionMode().
|
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 496 of file qquickpointerhandler.cpp.
References approveGrabTransition(), canGrab(), QPointerEvent::exclusiveGrabber(), qCDebug, QPointerEvent::setExclusiveGrabber(), and this.
Referenced by QQuickMultiPointHandler::grabPoints(), QQuickSinglePointHandler::handleEventPoint(), and QQuickTableViewResizeHandler::updateDrag().
void QQuickPointerHandler::setGrabPermissions | ( | GrabPermissions | grabPermissions | ) |
Definition at line 443 of file qquickpointerhandler.cpp.
References d, emit, and grabPermissionChanged().
Referenced by QQuickTableViewResizeHandler::QQuickTableViewResizeHandler(), and QQuickSelectionRectanglePrivate::createHandle().
Definition at line 92 of file qquickpointerhandler.cpp.
References d, emit, and marginChanged().
Referenced by QQuickTableViewHoverHandler::QQuickTableViewHoverHandler(), and QQuickTableViewResizeHandler::QQuickTableViewResizeHandler().
void QQuickPointerHandler::setParentItem | ( | QQuickItem * | p | ) |
Definition at line 661 of file qquickpointerhandler.cpp.
References QQuickItemPrivate::addPointerHandler(), d, emit, QQuickItemPrivate::get(), QObject::parent(), parent, qCDebug, QQuickItemPrivate::removePointerHandler(), and QObject::setParent().
Referenced by QQuickSelectionRectanglePrivate::createHandle().
|
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 292 of file qquickpointerhandler.cpp.
References QQuickDeliveryAgentPrivate::currentOrItemDeliveryAgent(), parentItem(), and qCDebug.
Referenced by QQuickPointHandler::handleEventPoint(), QQuickDragHandler::handlePointerEventImpl(), QQuickPinchHandler::handlePointerEventImpl(), and QQuickTableViewResizeHandler::updateDrag().
void QQuickPointerHandler::setTarget | ( | QQuickItem * | target | ) |
Definition at line 622 of file qquickpointerhandler.cpp.
References d, emit, onTargetChanged(), target, and targetChanged().
Referenced by QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate(), and QQuickSelectionRectanglePrivate::createHandle().
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 614 of file qquickpointerhandler.cpp.
References d, and parentItem().
|
signal |
|
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 781 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().
|
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.
Reimplemented in QQuickDragHandler, QQuickHoverHandler, QQuickMultiPointHandler, QQuickPinchHandler, QQuickPointerDeviceHandler, QQuickSinglePointHandler, and QQuickWheelHandler.
Definition at line 753 of file qquickpointerhandler.cpp.
Referenced by handlePointerEvent(), and QQuickPointerDeviceHandler::wantsPointerEvent().
|
friend |
Definition at line 146 of file qquickpointerhandler_p.h.
|
friend |
Definition at line 147 of file qquickpointerhandler_p.h.
|
friend |
Definition at line 148 of file qquickpointerhandler_p.h.
|
read |
Definition at line 155 of file qquickpointerhandler_p.h.
Referenced by QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate(), QQuickSelectionRectanglePrivate::createHandle(), QQuickDragHandler::handlePointerEventImpl(), QQuickPinchHandler::handlePointerEventImpl(), QQuickDragHandler::onActiveChanged(), QQuickMultiPointHandler::onActiveChanged(), QQuickPinchHandler::onActiveChanged(), QQuickWheelHandler::onActiveChanged(), setActive(), QQuickDragHandler::wantsPointerEvent(), QQuickMultiPointHandler::wantsPointerEvent(), and QQuickWheelHandler::wantsPointerEvent().
|
readwrite |
Definition at line 155 of file qquickpointerhandler_p.h.
Referenced by QQuickPinchHandler::handlePointerEventImpl().
|
readwrite |
Definition at line 155 of file qquickpointerhandler_p.h.
Referenced by QQuickPinchHandler::handlePointerEventImpl(), and setEnabled().
|
readwrite |
Definition at line 155 of file qquickpointerhandler_p.h.
Referenced by approveGrabTransition().
|
readwrite |
Definition at line 155 of file qquickpointerhandler_p.h.
Referenced by QQuickTableViewHoverHandler::handleEventPoint(), and parentContains().
|
readwrite |
Definition at line 155 of file qquickpointerhandler_p.h.
Referenced by QQuickHoverHandler::QQuickHoverHandler(), QQuickPointerHandler(), QQuickHoverHandler::~QQuickHoverHandler(), QQuickHoverHandler::componentComplete(), componentComplete(), handlePointerEvent(), QQuickDragHandler::onActiveChanged(), QQuickDragHandler::onGrabChanged(), parentContains(), setParentItem(), and QQuickPointHandler::wantsEventPoint().
|
readwrite |
Definition at line 155 of file qquickpointerhandler_p.h.
Referenced by eventPos(), QQuickWheelHandler::handleEventPoint(), QQuickDragHandler::handlePointerEventImpl(), QQuickPinchHandler::handlePointerEventImpl(), QQuickMultiPointHandler::moveTarget(), QQuickSinglePointHandler::moveTarget(), QQuickPinchHandler::onActiveChanged(), QQuickDragHandler::onGrabChanged(), and setTarget().