PDA

View Full Version : QTableWidget Header showing unnecessary checkbox when used with QProxyStyle



deepal_de
12th January 2012, 07:41
hi,
i have added a QProxyStyle to get horizontal text in vertical QTreeHeader.In windows XP this header shows unnecessary checkbox in header.i have attached a image of this.Any one had this kind of problem?

This is because of the QProxyStyle that i applied.
Is there a better way to get my vertical header text written as horizontal.


this is the styled i used.



class MyHorizontalHeader: public QProxyStyle
{
public:
MyHorizontalHeader(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(270);
painter->drawText(0,10,header->text);
painter->restore();
return;
}
return QProxyStyle::drawControl(element, option, painter, widget);
}
};


7257

this is the vertical header of my tree view.. in the 1st column i don't have any text,from the 2nd column onwards i have text.

Thanks