class MyHorizontalHeader: public QProxyStyle
{
public:
MyHorizontalHeader
(QStyle *style
) : QProxyStyle
(style
) {}
{
if (element
== QStyle::CE_HeaderLabel) {
if (!hv || hv->orientation() != Qt::Horizontal)
{
return QProxyStyle::drawControl(element, option, painter, widget);
}
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);
}
};
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);
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks