def __init__(self): super().__init__() # 定义菜单 self.menu = QtWidgets.QMenu(self) # 删除操作 self.delete_item = QtWidgets.QAction("删除", self.menu) self.menu.addAction(self.delete_item) # 重命名操作 self.rename_item = QtWidgets.QAction("重命名", self.menu) self.menu.addAction(self.rename_item)
def init_menu(self) -> None: """ Create right click menu. """ self.menu = QtWidgets.QMenu(self) resize_action = QtWidgets.QAction("调整列宽", self) resize_action.triggered.connect(self.resizeColumnsToContents) self.menu.addAction(resize_action)