我正在使用经典的 QgraphicsView / QGraphicsScene / QGraphicsItem 框架。我在 QgraphicsView 中声明了一个上下文菜单:
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.__contextMenu)
然后稍后:
# ---------------------------------------------------------------------------
def __contextMenu(self, position):
""" """
# ----> Creating Context menu -----------------------------------
oTreeMenu = QtGui.QMenu()
etc ...
然后在 QGraphicsItem 实例类中,我使用 contextMenuEvent,如下所示:
# ---------------------------------------------------------------------------
def contextMenuEvent(self, event):
""" """
# ----> Creating Context menu -----------------------------------
oTreeMenu = QtGui.QMenu()
问题是 QGraphicsItem 事件完全被 QGraphicsView 覆盖。我应该如何着手获得它们?