diff options
| author | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-12-09 08:06:18 +0100 |
|---|---|---|
| committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-12-10 06:51:59 +0100 |
| commit | e58cb58b44a0381592cd0e6eb0da3d3d6f1c5ccc (patch) | |
| tree | 27ce55d00f38360501842b6f06a647f0c93045a6 /src/quick/handlers/qquickpointerhandler.cpp | |
| parent | af356e3bc87f8029026d1eaa345f7197c0705ffa (diff) | |
Allow reparenting Pointer Handlers
[ChangeLog][Event Handlers] The parent property of any Pointer Handler
is now settable.
Fixes: QTBUG-84730
Task-number: QTBUG-85926
Task-number: QTBUG-17286
Change-Id: Id738dd783de1acfbef9b5be203025040b0913008
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickpointerhandler.cpp')
| -rw-r--r-- | src/quick/handlers/qquickpointerhandler.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp index 4777f31b4b..2f38fe8973 100644 --- a/src/quick/handlers/qquickpointerhandler.cpp +++ b/src/quick/handlers/qquickpointerhandler.cpp @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcPointerHandlerDispatch, "qt.quick.handler.dispatch") Q_LOGGING_CATEGORY(lcPointerHandlerGrab, "qt.quick.handler.grab") Q_LOGGING_CATEGORY(lcPointerHandlerActive, "qt.quick.handler.active") +Q_DECLARE_LOGGING_CATEGORY(lcHandlerParent) /*! \qmltype PointerHandler @@ -626,6 +627,20 @@ QQuickItem *QQuickPointerHandler::parentItem() const return qmlobject_cast<QQuickItem *>(QObject::parent()); } +void QQuickPointerHandler::setParentItem(QQuickItem *p) +{ + if (QObject::parent() == p) + return; + + qCDebug(lcHandlerParent) << "reparenting handler" << this << ":" << parent() << "->" << p; + if (auto *oldParent = static_cast<QQuickItem *>(QObject::parent())) + QQuickItemPrivate::get(oldParent)->removePointerHandler(this); + setParent(p); + if (p) + QQuickItemPrivate::get(p)->addPointerHandler(this); + emit parentChanged(); +} + QQuickItem *QQuickPointerHandler::target() const { Q_D(const QQuickPointerHandler); @@ -725,7 +740,6 @@ void QQuickPointerHandler::handlePointerEventImpl(QPointerEvent *event) } /*! - \readonly \qmlproperty Item QtQuick::PointerHandler::parent The \l Item which is the scope of the handler; the Item in which it was declared. |
