Hi.
I use Runtime version 100.8 and Qt 5.15.0 .
The code is almost the same, but I can't get MouseEvent.
Connections{
target: mainMap
//can't get
function onMouseClicked() {
var clickP = mainMap.screenToLocation(mouse.x, mouse.y)
console.log(mouse.x)
}
//can get
onMouseClicked: {
var clickP = mainMap.screenToLocation(mouse.x, mouse.y)
console.log(mouse.x)
}
}
On the side where I can get MouseEvent, I will get the following error.
QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... }
What should I do in this situation?
Solved! Go to Solution.
Hi there.
I'm also a tad confused with the new connection syntax in Qt 5.15, will take some time to get used to.
Here's a formulation that worked for me, try giving this a go.
MapView {
id : mapView
anchors.fill: parent
focus: true
Map {
// add the ArcGISStreets basemap to the map
initBasemapStyle: Enums.BasemapStyleArcGISStreets
}
Connections {
target: mapView
function onMouseClicked(mouseEvent) {
console.log("x:", mouseEvent.x, "y:", mouseEvent.y)
}
}
}
Hi there.
I'm also a tad confused with the new connection syntax in Qt 5.15, will take some time to get used to.
Here's a formulation that worked for me, try giving this a go.
MapView {
id : mapView
anchors.fill: parent
focus: true
Map {
// add the ArcGISStreets basemap to the map
initBasemapStyle: Enums.BasemapStyleArcGISStreets
}
Connections {
target: mapView
function onMouseClicked(mouseEvent) {
console.log("x:", mouseEvent.x, "y:", mouseEvent.y)
}
}
}
Thanks!
It code is correct.
I can get MouseEvent.