Home > Mobile >  Detect when mouse hover an ui element other than Scene3D QML
Detect when mouse hover an ui element other than Scene3D QML

Time:12-30

I have a Qt3D application with a Scene3D QML object taht is used to render my 3D scene only, on top of that i have regular 2D qml item/objects to render my ui.

I want to modify the cursor's shape whenever the user is hovering on the 3d scene only, and to reset the cursor when he is entering any 2d widget.

Is there an elegant way of doing this ? I've tried to add a MouseArea on the Scene3D but this doesn't work. Or to add one after all the other so that it is the last to catch mouse events, but if I understand correctly that would mean that I would have to go back and add MouseArea to every QML component that I have.

Thank you for your help.

CodePudding user response:

I do not know what is your problem (as you posted no code) but following simple MouseArea (in Rectangle where the scene view is) seems to work for me:

MouseArea {
    hoverEnabled: true
    anchors.fill: parent
    cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
}

That resets back to ArrowCursor just fine.

  • Related