右键菜单
def Right_click(self,pos): row_num = -1 for i in self.tableWidget.selectionModel().selection().indexes(): row_num = i.row() # if row_num <2: menu = QMenu() item1 = menu.addAction(u"选项一") item2 = menu.addAction(u"选项二") item3 = menu.addAction(u"选项三") action = menu.exec_(self.tableWidget.mapToGlobal(pos)) if action == item1: txt = self.tableWidget.item(row_num,0).text(),self.tableWidget.item(row_num,1).text(),self.tableWidget.item(row_num,2) print(txt)