As suggested by the commentator, you can do this using a custom delegate. Unfortunately, QTreeView.setWordWrap(True) does not seem to have an effect (at least in Qt 4.8). In response to another question, we implemented word wrap functionality with a custom QStyledItemDelegate for QTreeView:
Delegate implementation for wordwrap in QTreeView (Qt / PySide / PyQt)?
This is just one of the ways to do this, there are other good ways, I'm sure, and note that this example is very simple, no editors or anything like that ...
import sys from PySide import QtGui, QtCore class SimpleTree(QtGui.QTreeView): def __init__(self, parent = None): QtGui.QTreeView.__init__(self, parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setGeometry(500,200, 400, 300) self.setUniformRowHeights(False)
source share