Mercurial > trustbridge
comparison ui/textoverlaybutton.cpp @ 722:b0929968562a
(Issue31) Add textoverlaybutton to show a text in the button.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 02 Jul 2014 18:35:30 +0200 |
parents | |
children | 0bb54205c55a |
comparison
equal
deleted
inserted
replaced
721:abc76948d8e5 | 722:b0929968562a |
---|---|
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
7 */ | |
8 | |
9 #include <QPaintEvent> | |
10 #include <QPainter> | |
11 #include <QFont> | |
12 #include <QApplication> | |
13 | |
14 #include <QDebug> | |
15 | |
16 #include "textoverlaybutton.h" | |
17 | |
18 void TextOverlayButton::paintEvent(QPaintEvent *e) | |
19 { | |
20 QToolButton::paintEvent(e); | |
21 QPainter painter(this); | |
22 QFont font; | |
23 QRect myRect = e->rect().translated(0, 10); | |
24 | |
25 //font.setFamily("Comic Sans MS"); | |
26 | |
27 font.setPixelSize(14); | |
28 font.setWeight(QFont::DemiBold); | |
29 painter.setFont(font); | |
30 | |
31 //painter.setPen(Qt::white); | |
32 //painter.drawText(myRect.translated(1,1), Qt::AlignCenter, "20"); | |
33 painter.setPen(qApp->palette().color(QPalette::ButtonText)); | |
34 painter.drawText(myRect, Qt::AlignCenter | Qt::AlignVCenter, mOverlay); | |
35 | |
36 return; | |
37 } |