def paint(self, painter: QtGui.QPainter, option: QtWidgets.QStyleOptionViewItem, index: QtCore.QModelIndex): painter.save() options = QtWidgets.QStyleOptionViewItem(option) self.initStyleOption(options, index) painter.translate(options.rect.left(), options.rect.top()) doc = QtGui.QTextDocument() doc.setHtml(self.makeHtml(index.data())) doc.drawContents(painter) painter.restore()
def setEditorData(self, editor: QWidget, index: QModelIndex) -> None: editor.selected_id = index.data()