Mercurial > trustbridge
view 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 |
line wrap: on
line source
/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik * Software engineering by Intevation GmbH * * This file is Free Software under the GNU GPL (v>=2) * and comes with ABSOLUTELY NO WARRANTY! * See LICENSE.txt for details. */ #include <QPaintEvent> #include <QPainter> #include <QFont> #include <QApplication> #include <QDebug> #include "textoverlaybutton.h" void TextOverlayButton::paintEvent(QPaintEvent *e) { QToolButton::paintEvent(e); QPainter painter(this); QFont font; QRect myRect = e->rect().translated(0, 10); //font.setFamily("Comic Sans MS"); font.setPixelSize(14); font.setWeight(QFont::DemiBold); painter.setFont(font); //painter.setPen(Qt::white); //painter.drawText(myRect.translated(1,1), Qt::AlignCenter, "20"); painter.setPen(qApp->palette().color(QPalette::ButtonText)); painter.drawText(myRect, Qt::AlignCenter | Qt::AlignVCenter, mOverlay); return; }