自定义CustomDelegate继承自QStyledItemDelegate,重写setModelData(self, editor, model, index)方法
def setModelData(self, editor, model, index): #print("__________setModelData_________________") print(model.data(index)) ##新的值,但是未保存到model中. reply = QMessageBox.question(widget, "title", "contenr", QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) if reply == QMessageBox.Yes: super(CustomDelegate, self).setModelData(editor, model, index) print(model.data(index)) ##新的值已经保存到model中
时间: 2024-10-14 06:24:25