Results 1 to 2 of 2

Thread: QHeaderView and ProxyStyle

  1. #1
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QHeaderView and ProxyStyle

    I want to create (subclass ?) QHeaderViewto 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!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QHeaderView and ProxyStyle

    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.
    Last edited by jpn; 13th September 2008 at 15:14.
    J-P Nurmi

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.