Capturing mouse movement over a MapView

711
2
Jump to solution
10-12-2018 01:22 AM
by Anonymous User
Not applicable

Is there any way to capture the mouse movement over a MapView?

The mousePositionChanged signal documentation is slightly mis-leading, because it only fires when the mouse button is held down while the mouse is moved. I'm looking for a signal similar to the onPositionChanged signal of a MouseArea.

I tried placing a MouseArea over my mapview, but then nothing propagates through to the MapView, i.e. can't pan or click (although mouse wheel zooming seems to work!?). I tried manually triggering all the MapView mouse signals (e.g. whenever the mouse area pressed signal fires I called mapView.mousePressed(mouse) etc) but still couldn't pan/move the map around.

So I guess I'm asking for either of two things:

1) a way to capture the mouse hover movement over a MapView so I don't have to use a MouseArea at all (my preference)

2) a way to place a MouseArea over a MapView to capture the mouse hover movement but still be able to navigate the map underneath.

mousePositionChanged(MouseEvent mouse)

Emitted when the mouse is moved over the GeoView.

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

Looks like we need to add some clarification to our doc. You can accomplish this with a MouseArea and accepting the mouse events to let everything propagate through. 

MapView {
    id: mapView
    anchors.fill: parent
    // add a map to the mapview
    Map {
        // add the BasemapTopographic basemap to the map
        BasemapTopographic {}
    }        

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        hoverEnabled: true
        onMouseXChanged: {
            console.log(mouse.x, mouse.y)
        }
        onPressed: mouse.accepted = false
    }
}

View solution in original post

2 Replies
ErwinSoekianto
Esri Regular Contributor

Looping in ArcGIS Runtime SDK for Qt‌ to see if people in that group have an explanation to the mis-leading documentation and explanation on the mouse event. 

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Looks like we need to add some clarification to our doc. You can accomplish this with a MouseArea and accepting the mouse events to let everything propagate through. 

MapView {
    id: mapView
    anchors.fill: parent
    // add a map to the mapview
    Map {
        // add the BasemapTopographic basemap to the map
        BasemapTopographic {}
    }        

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        hoverEnabled: true
        onMouseXChanged: {
            console.log(mouse.x, mouse.y)
        }
        onPressed: mouse.accepted = false
    }
}