From 15b049c07ec01c23931e389bb971eff5072d0f56 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Fri, 10 Sep 2010 23:12:02 +0200 Subject: [PATCH] fun with qpainterpath --- sface/screens/mainscreen.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sface/screens/mainscreen.py b/sface/screens/mainscreen.py index 00710a3..e8e2763 100644 --- a/sface/screens/mainscreen.py +++ b/sface/screens/mainscreen.py @@ -29,13 +29,20 @@ class ItemDelegate(QStyledItemDelegate): if data.startswith("*"): # already in the sliver data = " %s " % data[1:] - rect = option.rect fm = QFontMetrics(option.font) - w = fm.width(QString(data)) - rect.setWidth(w) + rect = option.rect + rect.setWidth(fm.width(QString(data))) + rect.setHeight(rect.height() - 2) + rect.setX(rect.x() + 1) + x, y, h, w = rect.x(), rect.y(), rect.height(), rect.width() + + path = QPainterPath() + path.addRoundedRect(x, y, w, h, 4, 4) painter.save() - painter.fillRect(rect, QColor.fromRgb(0, 250, 0)) + painter.setRenderHint(QPainter.Antialiasing) + painter.drawRoundedRect(rect, 4, 4) + painter.fillPath(path, QColor.fromRgb(0, 250, 0)) painter.setPen(QColor.fromRgb(0, 0, 0)) painter.drawText(option.rect, 0, QString(data)) painter.restore() -- 2.43.0