Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.8
-
None
Description
HoverHandler does not function correctly when the parent of the item it is in is clipped. If you run the code below, you will see that the right hand rectangle continues to show that it is hovered while in the clipped region to its left, and even more concerning it continues to show it is hovered when the left rectangle should be getting the sole hover event. If you comment out the line that sets clipping to true, then it behaves as expected with the left rectangle getting the sole hover event.
This incorrect behavior is also true even when it is not the immediate parent that is clipping, which makes it very difficult or even impossible to work around in a normal application.
import QtQuick 2.15 import QtQuick.Window 2.15 Window { width: 640 height: 480 visible: true title: qsTr("HoverHandlerBug") Rectangle{ id: leftRect width: 100 height: parent.height z: 99 border.color: "green" border.width: 3 color: leftHoverHandler.hovered ? border.color : "transparent" HoverHandler { id: leftHoverHandler } } Item { x: 150 width: parent.width - x height: parent.height // Setting clip to true here breaks rightHoverHandler as it does not respect the clip and furthermore // no longer respects the z-order of leftRect. If you log onPointChanged it will show that both are // handling the point changes as well, so it is not just the hovered state that is incorrect clip: true Rectangle{ id: rightRect height: parent.height width: parent.width + 100 x: -100 border.color: "red" border.width: 3 color: rightHoverHandler.hovered ? border.color : "transparent" HoverHandler { id: rightHoverHandler } } } }