PDA

View Full Version : QTreeView with custom delegate - row resizing problem



vshader
9th September 2011, 15:24
Hello

In my application, I am using QTreeView to display information. Because normally QTreeView does not allow to render HTML inside, I created small delegate which does it (internally, it uses QTextDocument). The delegate has implemented paint() and sizeHint() methods. And to this point, it seems to work properly.

Later, I have activated word wrapping in QTextDocument. The problem appears, when the line is longer than item width. In this case, text is wrapped inside QTextDocument properly, but the height of row in QTreeView does not change. So, some part of text is invisible, as it is out of the row area.

I have no idea, how to implement this correctly. I have read that the proper way of resizing rows is to do it through sizeHint(), but:
a) in this function, I have no access to current column width
b) it is NOT called during columns resizing, and this is also what I need to take care of

Could you give me any advice, how to properly solve this problem?