本文整理匯總了Python中PyQt5.Qt.QPen.setBrush方法的典型用法代碼示例。如果您正苦於以下問題:Python QPen.setBrush方法的具體用法?Python QPen.setBrush怎麽用?Python QPen.setBrush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.Qt.QPen
的用法示例。
在下文中一共展示了QPen.setBrush方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: draw_text
# 需要導入模塊: from PyQt5.Qt import QPen [as 別名]
# 或者: from PyQt5.Qt.QPen import setBrush [as 別名]
def draw_text(self, style, painter, option, widget, index, item):
tr = style.subElementRect(style.SE_ItemViewItemText, option, widget)
text = index.data(Qt.DisplayRole)
hover = option.state & style.State_MouseOver
if hover or gprefs['tag_browser_show_counts']:
count = unicode_type(index.data(COUNT_ROLE))
width = painter.fontMetrics().boundingRect(count).width()
r = QRect(tr)
r.setRight(r.right() - 1), r.setLeft(r.right() - width - 4)
painter.drawText(r, Qt.AlignCenter | Qt.TextSingleLine, count)
tr.setRight(r.left() - 1)
else:
tr.setRight(tr.right() - 1)
is_rating = item.type == TagTreeItem.TAG and not self.rating_pat.sub('', text)
if is_rating:
painter.setFont(self.rating_font)
flags = Qt.AlignVCenter | Qt.AlignLeft | Qt.TextSingleLine
lr = QRect(tr)
lr.setRight(lr.right() * 2)
br = painter.boundingRect(lr, flags, text)
if br.width() > tr.width():
g = QLinearGradient(tr.topLeft(), tr.topRight())
c = option.palette.color(QPalette.WindowText)
g.setColorAt(0, c), g.setColorAt(0.8, c)
c = QColor(c)
c.setAlpha(0)
g.setColorAt(1, c)
pen = QPen()
pen.setBrush(QBrush(g))
painter.setPen(pen)
painter.drawText(tr, flags, text)