The mistake is that in your delegate you are using anchors.fill from the rect to the parent item with margins of 8. Since you calculate the total size of the item to be the same as the text rect and then anchor the text item inside that with 8 pixel borders, you are shrinking the size of your mouse area by 8 pixels in all directions.
Here is a simplified delegate that should work better:
delegate: Rectangle {
color: "red"
width: textBlock.paintedWidth + 10
height: textBlock.paintedHeight
Text {
id: textBlock
text: name
font.pixelSize: 20
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: { console.log("entered") }
}
}
↧