def setEditorData(self, editor: QWidget, index: QModelIndex): currentText = str(index.data(Qt.EditRole)) cbIndex = editor.findText(currentText) if (cbIndex >= 0): editor.setCurrentIndex(cbIndex)
def setEditorData(self, editor: QtWidgets.QWidget, index: QtCore.QModelIndex): # get the index of the text in the combobox that matches the current value of the item cbox_index = editor.findText(index.data(QtCore.Qt.EditRole)) if cbox_index: # if we know about this value, set it already editor.setCurrentIndex(cbox_index)