PDA

View Full Version : QHeaderView and ProxyStyle



caduel
31st August 2008, 12:32
I want to create (subclass ?) QHeaderView to support drawing texts vertically (I am thinking of long descriptions for very short contents...).

As QHeaderView::paintSection() does not really paint by itself, but rather via its style, I have subclassed QCommonStyle, reimplemented QCommonStyle::drawControl() and got that to work: the labels (those sections configured via an item role) were drawn vertically.

I then remembered reading about ProxyStyle.
I changed my code to use that.
However, once the ProxyStyle called the style (via its member variable), that style does not know about my proxy.
As QCommonStyle (e.g.) calls itself to delegate various subtasks, my ProxyStyle is just getting called once (for the part I do not want to modify). My modification to the subtask is not getting called.

Has anyone experience in how that could be achieved?
(I don't see how I can work around that in/with ProxyStyle.)

Best regards, and thank you
Christoph

PS: If someone knows a better way to achieve my original goal of drawing header labels vertically, I'd be interested in that as well!

jpn
13th September 2008, 14:09
Instead of reimplementing the "high-level" QStyle::drawControl(CE_Header), wouldn't it be sufficient to reimplement "lower-level" functions:

QStyle::subElementRect(SE_HeaderLabel)
QStyle::drawControl(CE_HeaderLabel)
QStyle::subElementRect(SE_HeaderArrow)
QStyle::drawPrimitive(PE_IndicatorHeaderArrow)

?

EDIT: Nevermind, of course the request still gets delegated to the "wrong" style object.