AnsweredAssumed Answered

Drawing on the map with mouse gestures

Question asked by on Sep 20, 2018
Latest reply on Sep 24, 2018 by



I'm working on an application that needs to allow the user to draw certain graphical objects on top of the map view (in MapGraphicsView). The problem I'm having is, to some extent, related also to the default behavior of the MapGraphicsView when the user presses the left mouse button and moving the mouse while holding the button down. The default behavior is that when the user moves the mouse with the left button down, it pans the map.

I've learnt the intended way to stop the map from being panned by calling accept() on the event object inside the geoViewMouseMoveEvent virtual method of my subclass.

Now what I need to achieve is to draw in response to the mouse movement, for instance a line from the starting point where the user pressed down the mouse, to the current mouse cursor position in real time while the user keeps the button down. I also will need to show some tooltip-like numerical info along the drawn line.


When I call accept() on the event object, it not only stops the map from being panned, but it also stops any paintEvent to be fired while moving the mouse with the button pressed (and consequentially no drawForground or drawBackground get called) until the accept() stops being called.

I tried to call update() from inside the geoViewMouseMoveEvent hoping that it would coerce the MapGraphicsView to call painting  methods but with no success.


My question is:

How do I achieve painting/redrawing to be called while blocking the map panning (as described above) when the user presses the left mouse button down and drags the mouse?


Thank you in advance



mapgraphicsview painting