def contextMenuEvent(self, event):
menu = QtWidgets.QMenu()
listOfLabelsAndFunctions = [
("interpolation Type", self.changeInterpolationType),
("CC Value", self.changeCCValue),
("delete", self.delete), #deletes the last hover item which is of course the current one.
]
for text, function in listOfLabelsAndFunctions:
if text == "separator":
self.addSeparator()
else:
a = QtWidgets.QAction(text, menu)
menu.addAction(a)
a.triggered.connect(function)
pos = QtGui.QCursor.pos()
pos.setY(pos.y() + 5)
self.ungrabMouse() #if we don't ungrab and the user clicks the context menu "away" by clicking in an empty area this will still get registered as mouseclick belonging to the current item and change the value to some insane amount, breaking the point.
menu.exec_(pos)
评论列表
文章目录