subsurface/backend-shared/roundrectitem.cpp
Berthold Stoeger b188560ae5 ui: create a RoundRectItem class
Factor out code from ProfileWidget's ToolTipItem, but make
the radius of the corners dynamic. Move into backend-shared,
though a new ui-shared might be preferred.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03 13:56:05 -08:00

18 lines
500 B
C++

#include "roundrectitem.h"
#include <QPainter>
#include <QStyleOptionGraphicsItem>
RoundRectItem::RoundRectItem(double radius, QGraphicsItem *parent) : QGraphicsRectItem(parent),
radius(radius)
{
}
void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
painter->save();
painter->setClipRect(option->rect);
painter->setPen(pen());
painter->setBrush(brush());
painter->drawRoundedRect(rect(), radius, radius, Qt::AbsoluteSize);
painter->restore();
}