主要代码:
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import *
app = QApplication(sys.argv)
tableWidget = QTableWidget()
tableWidget.setContextMenuPolicy(Qt.CustomContextMenu)
def openMenu(position):
menu = QMenu()
quitAction = menu.addAction("Quit")
action = menu.exec_(tableWidget.mapToGlobal(position))
if action == quitAction:
qApp.quit()
tableWidget.customContextMenuRequested.connect(openMenu)
tableWidget.show()
sys.exit(app.exec_())
我想使用lambda并传递参数:
tableWidget.customContextMenuRequested.connect(lambda: openMenu(?))
但是参数 position 是什么?