24 #include <QApplication>
25 #include <QStyleOption>
26 #include <QStylePainter>
38 setToggleButton(
true);
39 setAutoDefault(
false);
40 setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
65 QString _text = text();
68 QFontMetrics fm = this->fontMetrics();
69 int w = fm.height()+5;
70 int h = 24+fm.width(_text);
71 QStyleOption *so=
new QStyleOption();
73 QSize sz=style()->sizeFromContents(
74 QStyle::CT_ToolButton,
75 so, QSize(w, h).expandedTo(QApplication::globalStrut()));
82 QStyle::State st = QStyle::State_None | QStyle::State_Enabled;
84 st |= QStyle::State_On;
85 st |= QStyle::State_DownArrow;
88 QRect r(0, 0, height(), width());
91 p->translate(0, height());
95 p->translate(width(), 0);
98 QStyleOption *so=
new QStyleOption();
100 style()->drawControl(QStyle::CE_PushButton, so,p);
101 style()->drawControl(QStyle::CE_PushButtonLabel, so,p);
108 QPushButton::setText(s);
110 setFixedHeight(sz.height());
111 setFixedWidth(sz.width());
123 QStylePainter p(
this);
126 p.translate(-height(), 0);
135 QStyleOptionButton opt;
138 QSize size = opt.rect.size();
140 opt.rect.setSize(size);
142 opt.features = QStyleOptionButton::None;
144 opt.features |= QStyleOptionButton::Flat;
146 opt.features |= QStyleOptionButton::HasMenu;
147 if (autoDefault() || isDefault())
148 opt.features |= QStyleOptionButton::AutoDefaultButton;
150 opt.features |= QStyleOptionButton::DefaultButton;
152 opt.state |= QStyle::State_Sunken;
154 opt.state |= QStyle::State_On;
155 if (!isFlat() && !isDown())
156 opt.state |= QStyle::State_Raised;
159 opt.iconSize = iconSize();
QStyleOptionButton getStyleOption() const
virtual QSize sizeHint() const
virtual void setText(const QString &s)
void paintEvent(QPaintEvent *event)
void setPosition(VTabPosition p_pos)
VTab(VTabPosition pos=TabLeft, int p_id=-1, QWidget *parent=0l, const char *name=0l)
virtual void drawButton(QPainter *p)
void toggled(int p_id, bool p_state)