本文整理匯總了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)