Select to view content in your preferred language

Disable Map's double click zoom

4598
2
01-21-2014 09:24 AM
EricHeine
New Contributor
Hi, I'm trying to have a custom mode where double clicking on a map will do something that isn't zooming into a point, but I can't seem to disable the built in functionality to zoom in to where the user double clicked.  I'm fairly certain that just marking the event as accepted isn't going to work since the signal isn't passing a reference to the QMouseEvent, but a copy of it.  Is there some other way to disable the zoom on double click functionality?

Thanks,
Eric
0 Kudos
2 Replies
JeffHoude
New Contributor
I have been looking into this problem as well, and I have not found any official solution that works with the Qt sdk.  I have found solutions that supposedly work with Java and Python etc, but it doesn't seem to be something supported for Qt.  However, I have stumbled onto a solution that is somewhat of a hack.

Within the double click event handler, if you retrieve the current zoom scale and then apply a zoomToScale to it, it will override whatever active zooming was applied by the default double click handler and basically disable the zoom animation.

connect(&map, SIGNAL(mouseDoubleClick(QMouseEvent)), this, SLOT(onMouseDoubleClick(QMouseEvent)));

void onMouseDoubleClick(QMouseEvent event)
{
    double scale = map.scale();
    map.zoomToScale(scale);
}


If anyone has a better solution, please share.

-Jeff
0 Kudos
MichaelTims
Occasional Contributor
To handle interception of the mouseDoubleClick event on the GraphicsScene, you must subclass QGraphicsItem, accept mouseDoubleClick, and add this item to the GraphicsScene (MapGraphicsView::scene()).

There are a few examples in the QtSampleApplication sample code, which comes installed the Runtime SDK for Qt.
See the Search --> Local Geocode sample for information on how to intercept double click events from the Map's scene.
0 Kudos