I would like to have a pop-up menu when right-clicking the MapCanvas
(the identifyFeatures tool does it...)
Could anybody give me a starting point on how to achieve this?
SnaileaterSnaileater
asked Jun 13, 2015 at 6:15
1 Answer 1
Should have searched a bit more (...) :
class showMenu(QgsMapTool):
def __init__(self, iface):
canvas = iface.mapCanvas()
QgsMapTool.__init__(self,canvas)
self.canvas = canvas
def canvasPressEvent(self,e):
if e.button() == Qt.RightButton:
menu = QMenu()
quitAction = menu.addAction("AnyAction")
action = menu.exec_(self.canvas.mapToGlobal(QPoint(e.pos().x()+5, e.pos().y())))
Kadir Şahbaz
78.6k57 gold badges260 silver badges407 bronze badges
answered Jun 13, 2015 at 10:34
-
You could also override the messageEmitted method to display a message to the user.Matt– Matt2015年07月25日 09:10:37 +00:00Commented Jul 25, 2015 at 9:10
lang-py