Implementing a delegate for wordwrap in a QTreeView (Qt/PySide/PyQt)?
I have a tree view with a custom delegate to which I am trying to add word wrap functionality. The word wrapping is working fine, but the sizeHint() seems to not work, so when the text wraps, the relevant row does not expand to include it. I thought I was taking care of it in sizeHint() by returning document.size().height() . def sizeHint(self, option, index): text = index.model().data(index) document = QtGui.QTextDocument() document.setHtml(text) document.setTextWidth(option.rect.width()) return QtCore.QSize(document.idealWidth(), document.size().height()) However, when I print out document