aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickhoverhandler.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-03-09 21:41:06 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2021-06-03 23:44:48 +0200
commit1285b67a113cd2eb4fc03ec3e4ddd4dfdbe8ae76 (patch)
treeeae0752feef315b38a10e8b8802086bdedf27bde /src/quick/handlers/qquickhoverhandler.cpp
parent21a458e16efdb5a56ae2ffe83b01eb6a1baf9302 (diff)
Allow pointer handlers to be added to QQuick3DModel objects
Mainly it's a matter of removing the assumption that parent() is always a QQuickItem. But handlers that have a target property do not know how to manipulate it when it's not an item; so for example you can use DragHandler's translation property to manipulate the object, but it doesn't drag a 3D object by default. Delivery logic for now is implemented in QQuick3DViewport, because it's intimately tied to picking, and QQuickDeliveryAgent doesn't really know anything about QQ3D objects, and the conventional delivery to handlers in Qt Quick depends on QQuickItemPrivate::handlePointerEvent() which isn't available in that use case. Hover events are interfering with DragHnadler (wantsPointerEvent() returns false, therefore the handler gets deactivated right away). HoverHandler detects hover but does not detect leave, but that's probably a matter for the delivery logic to fix. Change-Id: Id0ec385ce8df3a003f72a6666d16632cef72bbd6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickhoverhandler.cpp')
-rw-r--r--src/quick/handlers/qquickhoverhandler.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/quick/handlers/qquickhoverhandler.cpp b/src/quick/handlers/qquickhoverhandler.cpp
index b934940126..020afc647a 100644
--- a/src/quick/handlers/qquickhoverhandler.cpp
+++ b/src/quick/handlers/qquickhoverhandler.cpp
@@ -101,8 +101,10 @@ bool QQuickHoverHandler::event(QEvent *event)
void QQuickHoverHandler::componentComplete()
{
- parentItem()->setAcceptHoverEvents(true);
- QQuickItemPrivate::get(parentItem())->setHasHoverInChild(true);
+ if (auto par = parentItem()) {
+ par->setAcceptHoverEvents(true);
+ QQuickItemPrivate::get(par)->setHasHoverInChild(true);
+ }
}
bool QQuickHoverHandler::wantsPointerEvent(QPointerEvent *event)