How to word wrap a QTreeWidgetItem

pyqt, qt4

Solution

I successfully found a workaround: i envelope a QLabel in the WidgetItem, setting the QLabel to have word wrap capabilities.

item = QTreeWidgetItem()
label = QLabel('long text here')
label.setWordWrap(True)

MyTree.addTopLevelItem(item)
MyTree.setItemWidget(item, 0, label)

the behaviour is exactly the one desired!!

Problem

I have to populate a QTreeWidget with items (or children of items) that may happen to be too long to fit in a single line, so I'm looking for a way to word wrap them. I thought ``` myQTreeWidget.setWordWrap(True) ``` (done via QtDesigner4) would have done the job, but that doesn't seem to be the case. I don't know if it is relevant, but the tree is enveloped in a splitter frame, so the wrapping should be somehow dynamic to allow resizing of the splitter. Any ideas? I use PyQt4, but hints in any language/binding would be appreciated.

Original source

Related problems