本文整理汇总了Python中PySide.QtGui.QIcon.paint方法的典型用法代码示例。如果您正苦于以下问题:Python QIcon.paint方法的具体用法?Python QIcon.paint怎么用?Python QIcon.paint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QIcon
的用法示例。
在下文中一共展示了QIcon.paint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paint
# 需要导入模块: from PySide.QtGui import QIcon [as 别名]
# 或者: from PySide.QtGui.QIcon import paint [as 别名]
def paint(self, painter, option, index):
painter.save()
index0 = index.sibling( index.row(), 0 )
utype = index0.data( Qt.UserRole )
# # set background color
if option.state & QStyle.State_Selected:
painter.setPen ( Qt.NoPen )
painter.setBrush( GraphTreeItemDelegate._backgroundBrushSelected )
painter.drawRect(option.rect)
elif option.state & QStyle.State_MouseOver:
painter.setPen ( Qt.NoPen )
painter.setBrush( GraphTreeItemDelegate._backgroundBrushHovered )
painter.drawRect(option.rect)
rect = option.rect
icon = QIcon( index.data( Qt.DecorationRole) )
rect.adjust( 5, 0, 0, 0 )
if icon and not icon.isNull():
icon.paint( painter, rect, Qt.AlignLeft )
rect.adjust( 22, 0, 0, 0 )
text = index.data(Qt.DisplayRole)
if utype == 1: #GROUP
painter.setPen( GraphTreeItemDelegate._textPenGroup )
else:
painter.setPen( GraphTreeItemDelegate._textPen )
painter.drawText( rect, Qt.AlignLeft | Qt.AlignVCenter, text )
painter.restore()