[QGIS-Developer] Disabling map context menu via PyQGIS

Nyall Dawson nyall.dawson at gmail.com
Fri Sep 3 00:23:15 PDT 2021


On Fri, 3 Sept 2021 at 17:14, Johannes Kröger (WhereGroup)
<johannes.kroeger at wheregroup.com> wrote:
>
> Hi list!
>
> In QGIS 3.16 a right-click context menu was added to the map canvas:
> https://www.qgis.org/en/site/forusers/visualchangelog316/index.html#add-context-menu-to-map-canvas
>
> How can we disable that via PyQGIS?
>
> https://qgis.org/pyqgis/master/gui/QgsMapCanvas.html lists a
> "contextMenuEvent" method but does not provide any documentation at all.
>
> The environment is a QGIS based standalone application.

Make sure your map tool doesn't return the QgsMapTool::ShowContextMenu
flag.  (Or subclass the inbuilt tool you are using and override its
flags() implementation)

Nyall

>
> Cheers, Hannes
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list