resizing QHeaderView with drawcontrol
===

I've used the following code to set a style for the QApplication I am running:


    class MyStyle : public QProxyStyle
    {
    public:
        MyStyle(QStyle *style) : QProxyStyle(style) {}
        void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter,
                         const QWidget *widget = 0) const
        {
            if (element == QStyle::CE_HeaderLabel) {
                const QHeaderView *hv = qobject_cast<const QHeaderView *>(widget);
                if (!hv || hv->orientation() != Qt::Horizontal)
                    return QProxyStyle::drawControl(element, option, painter, widget);
                const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option);
                painter->save();
                painter->translate(header->rect.bottomLeft());
                painter->rotate(-40);
                painter->drawText(0,0,100,500,Qt::AlignLeft,header->text);
                painter->restore();
                return;
            }
            return QProxyStyle::drawControl(element, option, painter, widget);
        }
    };

When I make a QTreeWidget (it uses a QHeaderView), I get the following not-so-impressive result:
![enter image description here][1]

It seems that the header does not have enough space? Or the painter is just painting outside bounds? In either case, I need to both increase the height of the `QHeaderView` and 
keep the painter inside bounds. I've playing around with the widgth and height params in

`painter->drawText(0,0,w,h,flag,text)` 

but it doesn't seem to help anyway.

In case, you are wondering, this code is indeed a modified version of the faq answer on [how to draw vertical text in a QHeaderView][2]. 


  [1]: http://i.stack.imgur.com/1VVMA.png
  [2]: http://qt-project.org/faq/answer/how_can_i_display_vertical_text_in_the_section_of_a_qheaderview