本文整理汇总了Python中PyQt5.QtWidgets.QStyleOption.rect方法的典型用法代码示例。如果您正苦于以下问题:Python QStyleOption.rect方法的具体用法?Python QStyleOption.rect怎么用?Python QStyleOption.rect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QStyleOption
的用法示例。
在下文中一共展示了QStyleOption.rect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawIndicatorIcon
# 需要导入模块: from PyQt5.QtWidgets import QStyleOption [as 别名]
# 或者: from PyQt5.QtWidgets.QStyleOption import rect [as 别名]
def drawIndicatorIcon(palette, style):
pix = QPixmap(14, 14)
pix.fill(Qt.transparent)
branchOption = QStyleOption()
#r = QRect(QPoint(0, 0), pix.size())
branchOption.rect = QRect(2, 2, 9, 9) ## ### hardcoded in qcommonstyle.cpp
branchOption.palette = palette
branchOption.state = QStyle.State_Children
p = QPainter()
## Draw closed state
p.begin(pix)
style.drawPrimitive(QStyle.PE_IndicatorBranch, branchOption, p)
p.end()
rc = QIcon(pix)
rc.addPixmap(pix, QIcon.Selected, QIcon.Off)
## Draw opened state
branchOption.state |= QStyle.State_Open
pix.fill(Qt.transparent)
p.begin(pix)
style.drawPrimitive(QStyle.PE_IndicatorBranch, branchOption, p)
p.end()
rc.addPixmap(pix, QIcon.Normal, QIcon.On)
rc.addPixmap(pix, QIcon.Selected, QIcon.On)
return rc
示例2: paintEvent
# 需要导入模块: from PyQt5.QtWidgets import QStyleOption [as 别名]
# 或者: from PyQt5.QtWidgets.QStyleOption import rect [as 别名]
def paintEvent(self, event):
QToolButton.paintEvent(self, event)
painter = QPainter(self)
opt = QStyleOption()
opt.initFrom(self)
opt.rect = QRect(6, self.rect().center().y() - 3, 8, 8)
opt.rect.translate(0, -3)
style = self.style()
style.drawPrimitive(QStyle.PE_IndicatorArrowUp, opt, painter, self)
opt.rect.translate(0, 6)
style.drawPrimitive(QStyle.PE_IndicatorArrowDown, opt, painter, self)
示例3: paint_drop_indicator
# 需要导入模块: from PyQt5.QtWidgets import QStyleOption [as 别名]
# 或者: from PyQt5.QtWidgets.QStyleOption import rect [as 别名]
def paint_drop_indicator(self, painter):
if self.drag_active:
opt = QStyleOption()
opt.initFrom(self)
opt.rect = self.drop_indicator_rect
rect = opt.rect
brush = QBrush(QColor(Qt.darkRed))
if rect.height() == 0:
pen = QPen(brush, 2, Qt.SolidLine)
painter.setPen(pen)
painter.drawLine(rect.topLeft(), rect.topRight())
else:
pen = QPen(brush, 2, Qt.SolidLine)
painter.setPen(pen)
painter.drawRect(rect)