3

I would like to have a QTreeWidgetItem display formatted html.(PyQt) Has anyone successfully managed this?

htmlString = r"<b>BoldText:</b>SomeValue"
item = QtGui.QTreeWidgetItem( item, [htmlString], 0)

Any help greatly appreciated!

tranimatronic
  • 171
  • 1
  • 5
  • You need to set up a custom delegate. See discussion here: https://stackoverflow.com/questions/1956542/how-to-make-item-view-render-rich-html-text-in-qt – amm Dec 03 '20 at 18:36

1 Answers1

4

to answer my own question: I created a widget containing a QTextEdit and used setHtml() to display htmlString Then added this widget to the tree:

anItem = QtGui.QTreeWidgetItem( parentWidgt )
parentWidgt.setItemWidget(anItem, 0, widgContainingTextEdit)

Cheers!

tranimatronic
  • 171
  • 1
  • 5