Mercurial > trustbridge
comparison ui/textoverlaybutton.cpp @ 932:57371f2e8dae
(issue72) Set background image as pixmap in textoverlayicon
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 22 Aug 2014 16:20:25 +0200 |
parents | a467204a35f5 |
children | 947a880ec5d3 |
comparison
equal
deleted
inserted
replaced
931:7ac5a366184d | 932:57371f2e8dae |
---|---|
28 painter.setRenderHint(QPainter::Antialiasing, true); | 28 painter.setRenderHint(QPainter::Antialiasing, true); |
29 | 29 |
30 QRect myRect = e->rect().translated(26, -29); | 30 QRect myRect = e->rect().translated(26, -29); |
31 | 31 |
32 // circle | 32 // circle |
33 /* old manually painted background | |
33 QLinearGradient gradient(myRect.topLeft(), | 34 QLinearGradient gradient(myRect.topLeft(), |
34 myRect.bottomRight()); | 35 myRect.bottomRight()); |
35 gradient.setColorAt(0, Qt::white); | 36 gradient.setColorAt(0, Qt::white); |
36 gradient.setColorAt(0.7, Qt::red); | 37 gradient.setColorAt(0.7, Qt::red); |
37 QBrush brush(gradient); | 38 QBrush brush(gradient); |
38 painter.setBrush(brush); | 39 painter.setBrush(brush); |
39 painter.setPen(Qt::white); | 40 painter.setPen(Qt::white); |
40 painter.drawEllipse(75.5, 6, 20, 20); | 41 painter.drawEllipse(75.5, 6, 20, 20); |
42 */ | |
43 painter.drawPixmap(75.5, 5, mBackground); | |
41 | 44 |
42 // font | 45 // font |
43 QFont font; | 46 QFont font; |
44 font.setPixelSize(11); | 47 font.setPixelSize(11); |
45 font.setWeight(QFont::Bold); | 48 font.setWeight(QFont::Bold); |
46 painter.setFont(font); | 49 painter.setFont(font); |
47 painter.drawText(myRect, Qt::AlignCenter | Qt::AlignVCenter, mOverlay); | 50 painter.drawText(myRect, Qt::AlignCenter | Qt::AlignVCenter, mOverlay); |
48 | 51 |
49 return; | 52 return; |
50 } | 53 } |
54 | |
55 void TextOverlayButton::setBackgroundIcon (const QString& iconPath) { | |
56 mBackground = QIcon(iconPath).pixmap(QSize(22,22)); | |
57 } |