PDA

View Full Version : Text orientation in header from QStandardItemModel



Tondog
2nd September 2011, 08:16
Is it possible to turn a text in a header from a QStandardItemModel? I can't find a soloution.

Djab
1st October 2012, 16:34
I've got the same issue, and can't find a solution.

If anyone have any suggestion..

My latest test, I've subclassed qheaderview.html define qheaderview.html#paintSection as this:


class VerticalTextHeaderView(QtGui.QHeaderView):
def __init__(self, *args, **kwargs):
QtGui.QHeaderView.__init__(self, *args, **kwargs)

def paintSection(self, painter, rect, logicalIndex):
painter.rotate(-90)
return QtGui.QHeaderView.paintSection(self, painter, rect, logicalIndex)


But the results are not really appropriate...
Not really sure about what to do.

ChrisW67
2nd October 2012, 04:56
Well, since a model doesn't have a header the original (year-old) question makes little sense.

Your approach with replacing the header view painting is good but you may also need to translate the drawing to keep it visible, and adjust the size of the sections (reimp. sectionSizeFromContents()) for the narrower width/taller height.

Djab
2nd October 2012, 08:39
Thanks Chris for your answer !
I thought, I needed to do something for the dimensions... but i didn't know how, thanks !

I'm not sure to understand what you mean here:

you [...] need to translate the drawing to keep it visible

Could you be more precise ?