def paintEvent(self, ev): p = QPainter(self) c = color('tab tree background', None) if c: p.fillRect(ev.rect(), QColor(c)) p.end() QWidget.paintEvent(self, ev)
def paintEvent(self, ev): if not self.static_text or not self.static_text.text(): return p = QPainter(self) p.setRenderHint(QPainter.RenderHint.TextAntialiasing) # If text is too long too fit, fade it out at the end self.static_text.setTextWidth(self.rect().width()) sz = self.static_text.size() r = self.rect() p.drawStaticText(0, int(r.height() - sz.height()) // 2, self.static_text) if sz.width() > r.width(): g = QLinearGradient(QPointF(self.rect().topLeft()), QPointF(self.rect().topRight())) c = QColor(self.sb_background) c.setAlpha(0) g.setColorAt(0, c) g.setColorAt(0.8, c) g.setColorAt(1.0, self.sb_background) p.fillRect(self.rect(), QBrush(g)) p.end()