def createEditor(self, parent, option, index): column = index.column() fieldType = FieldsMappingModel.columns[column]['type'] if fieldType == QVariant.Type: editor = QComboBox(parent) for key, text in FieldsMappingModel.fieldTypes.iteritems(): editor.addItem(text, key) elif fieldType == QgsExpression: editor = QgsFieldExpressionWidget(parent) editor.setLayer(index.model().layer()) editor.fieldChanged.connect(self.on_expression_fieldChange) else: editor = QStyledItemDelegate.createEditor(self, parent, option, index) editor.setAutoFillBackground(True) return editor