我正在經典的QgraphicsView/QGraphicsScene/QGraphicsItem框架。後來PyQt QgraphicsItem上下文菜單被QGraphicsView覆蓋Contextmenu
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.__contextMenu)
然後: 我在的QGraphicsView聲明上下文菜單
# ---------------------------------------------------------------------------
def __contextMenu(self, position):
""" """
# ----> Creating Context menu -----------------------------------
oTreeMenu = QtGui.QMenu()
etc ...
然後在實例化的QGraphicsItem I類使用的ContextMenuEvent類似如下:
# ---------------------------------------------------------------------------
def contextMenuEvent(self, event):
""" """
# ----> Creating Context menu -----------------------------------
oTreeMenu = QtGui.QMenu()
問題是QGraphicsItem事件被QGraphicsView完全覆蓋。 我應該如何着手解決這兩個問題?