def setEditorData(self, editor, index): """ load data from model to editor """ m = index.model() if index.column() == 1: txt = m.data(index, Qt.DisplayRole) editor.setEditText(txt) else: # use default QItemDelegate.setEditorData(self, editor, index)
def setEditorData(self, editor, index): """ load data from model to editor """ m = index.model() try: if index.column() == self.column: txt = m.data(index, Qt.DisplayRole) checkList = txt[1:-1].split(',') for i in range(editor.count()): item = editor.item(i) item.setCheckState(Qt.Checked if item.text() in checkList else Qt.Unchecked) else: # use default QItemDelegate.setEditorData(self, editor, index) except: pass