Select to view content in your preferred language

Overriding MapView methods

712
1
Jump to solution
09-01-2017 06:43 AM
NicholasLiccini
Emerging Contributor

Hi!

I would like to subclass the MapView class (for the C++/QtQuick template) so that mouse events have different results. For example, I don't want double clicking on the map to zoom in.

How would I go about extending this class and overriding those methods?

Nick

0 Kudos
1 Solution

Accepted Solutions
LukeSmallwood
Esri Contributor

Hi Nicholas,

To change the behaviour of double-click you could derive your own view type from MapQuickView (or MapGraphicsView) and override this protected method:

virtual void mouseDoubleClickEvent(QMouseEvent *event);

This would let you simply ignore double-clicks on the view - if you need double-clicks to do something else you may be able to add that here as well.

You should make sure that your implementation still calls through to the event on the base QuickItem like so:

QQuickItem::mouseDoubleClickEvent(event);

and then depending on what you want to happen you may want to accept or ignore the event. 

It is also possible to derive your view type from MapView (rather than MapQuickView) but this would require implementing a lot more of the interface - see MapView Class | ArcGIS for Developers .

Hopefully that is helpful.

Luke

View solution in original post

1 Reply
LukeSmallwood
Esri Contributor

Hi Nicholas,

To change the behaviour of double-click you could derive your own view type from MapQuickView (or MapGraphicsView) and override this protected method:

virtual void mouseDoubleClickEvent(QMouseEvent *event);

This would let you simply ignore double-clicks on the view - if you need double-clicks to do something else you may be able to add that here as well.

You should make sure that your implementation still calls through to the event on the base QuickItem like so:

QQuickItem::mouseDoubleClickEvent(event);

and then depending on what you want to happen you may want to accept or ignore the event. 

It is also possible to derive your view type from MapView (rather than MapQuickView) but this would require implementing a lot more of the interface - see MapView Class | ArcGIS for Developers .

Hopefully that is helpful.

Luke