paint tab icon
This commit is contained in:
parent
4cfd16485c
commit
2a7f9cdd56
|
@ -133,6 +133,10 @@ void Tab::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
QStylePainter style(this);
|
QStylePainter style(this);
|
||||||
|
|
||||||
|
if (!icon().isNull()) {
|
||||||
|
style.translate(0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
QStyleOptionButton option;
|
QStyleOptionButton option;
|
||||||
initStyleOption(&option);
|
initStyleOption(&option);
|
||||||
option.features |= QStyleOptionButton::Flat;
|
option.features |= QStyleOptionButton::Flat;
|
||||||
|
@ -140,22 +144,17 @@ void Tab::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
style.drawControl(QStyle::CE_PushButtonLabel, option);
|
style.drawControl(QStyle::CE_PushButtonLabel, option);
|
||||||
|
|
||||||
|
|
||||||
if (!icon().isNull()) {
|
if (!icon().isNull()) {
|
||||||
const QSize &size = iconSize();
|
const QSize &size = iconSize();
|
||||||
icon().paint(&painter,
|
QRect iconPos(QPoint((width()-size.width())/2, 0), size);
|
||||||
QRect(QPoint((width()-size.width())/2, 0), size),
|
icon().paint(&painter, iconPos, Qt::AlignCenter, QIcon::Normal);
|
||||||
Qt::AlignCenter,
|
|
||||||
QIcon::Normal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
QPen pen;
|
QPen pen;
|
||||||
pen.setColor(Qt::red);
|
pen.setColor(Qt::red);
|
||||||
pen.setWidth(2);
|
pen.setWidth(5);
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
|
painter.setBrush(Qt::NoBrush);
|
||||||
painter.drawRect(rect());
|
painter.drawRect(rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue