Hi Hannes,

in C++ you could override
void QgsMapCanvas::showContextMenu( QgsMapMouseEvent *event )

which creates and shows the context menu.

in Python showContextMenu is not available. There you could re-implement
void QgsMapCanvas::mousePressEvent( QMouseEvent *e ) to avoid any calls of showContextMenu()

If you just like to modify the context menu, you might add a slot for the
void contextMenuAboutToShow( QMenu *menu, QgsMapMouseEvent *event ) signal that manipulates the menu.

Greetings,

Benjamin


So you might either override it or

to disable the context menu you can override QgsMapCanvas::mousePressEvent


Am 03/09/2021 um 09:14 schrieb Johannes Kröger (WhereGroup):

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.

Cheers, Hannes


_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

--
Benjamin Jakimow, Doctoral Researcher
Earth Observation Lab | Geography Department | Humboldt-Universität zu Berlin

e-mail: [email protected]

phone:  +49 (0) 30 2093 6846
mobile: +49 (0) 157 5656 8477
fax:    +49 (0) 30 2093 6848
mail:   Unter den Linden 6 | 10099 Berlin | Germany
room: 2'211
web:    https://hu-berlin.de/eo-lab

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to