Код: Выделить всё
class HtmlDelegate(QStyledItemDelegate):
def paint(self, painter, option, index):
# Skipping to retain category headers
if not index.parent().isValid():
super().paint(painter, option, index)
return
painter.save()
text = index.data()
doc = QTextDocument()
doc.setHtml(f"{text}
")
doc.setTextWidth(option.rect.width())
painter.translate(option.rect.topLeft())
doc.drawContents(painter)
painter.restore()
def sizeHint(self, option, index):
text = index.data()
doc = QTextDocument()
doc.setHtml(f"
{text}
")
doc.setTextWidth(option.rect.width())
return doc.size().toSize()
Подробнее здесь: https://stackoverflow.com/questions/796 ... pplication