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?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
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())))