[QGIS-Developer] Disabling map context menu via PyQGIS
Benjamin Jakimow
benjamin.jakimow at geo.hu-berlin.de
Fri Sep 3 00:31:06 PDT 2021
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
> 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
--
Benjamin Jakimow, Doctoral Researcher
Earth Observation Lab | Geography Department | Humboldt-Universität zu Berlin
e-mail: benjamin.jakimow at geo.hu-berlin.de
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210903/c1648556/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5422 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210903/c1648556/attachment-0001.bin>
More information about the QGIS-Developer
mailing list