本文整理汇总了Python中PyQt5.QtCore.QLineF.translated方法的典型用法代码示例。如果您正苦于以下问题:Python QLineF.translated方法的具体用法?Python QLineF.translated怎么用?Python QLineF.translated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QLineF
的用法示例。
在下文中一共展示了QLineF.translated方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawToolButtonMenuIndicator
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import translated [as 别名]
def drawToolButtonMenuIndicator(self, option, painter, widget=None):
arrow_rect = self.proxy().subControlRect(QStyle.CC_ToolButton, option, QStyle.SC_ToolButtonMenu, widget)
text_color = option.palette.color(
QPalette.WindowText if option.state & QStyle.State_AutoRaise else QPalette.ButtonText
)
button_color = option.palette.color(QPalette.Button)
background_color = self.background_color(button_color, 0.5)
painter.save()
# draw separating vertical line
if option.state & (QStyle.State_On | QStyle.State_Sunken):
top_offset, bottom_offset = 4, 3
else:
top_offset, bottom_offset = 2, 2
if option.direction == Qt.LeftToRight:
separator_line = QLineF(
arrow_rect.x() - 3,
arrow_rect.top() + top_offset,
arrow_rect.x() - 3,
arrow_rect.bottom() - bottom_offset,
)
else:
separator_line = QLineF(
arrow_rect.right() + 3,
arrow_rect.top() + top_offset,
arrow_rect.right() + 3,
arrow_rect.bottom() - bottom_offset,
)
light_gradient = QLinearGradient(separator_line.p1(), separator_line.p2())
light_gradient.setColorAt(
0.0, ColorScheme.shade(self.background_top_color(button_color), ColorScheme.LightShade, 0.0)
)
light_gradient.setColorAt(
1.0, ColorScheme.shade(self.background_bottom_color(button_color), ColorScheme.MidlightShade, 0.5)
)
separator_color = ColorScheme.shade(self.background_bottom_color(button_color), ColorScheme.MidShade, 0.0)
painter.setRenderHint(QPainter.Antialiasing, False)
painter.setPen(QPen(light_gradient, 1))
painter.drawLine(separator_line.translated(-1, 0))
painter.drawLine(separator_line.translated(+1, 0))
painter.setPen(QPen(separator_color, 1))
painter.drawLine(separator_line)
# draw arrow
arrow = QPolygonF([QPointF(-3, -1.5), QPointF(0.5, 2.5), QPointF(4, -1.5)])
if option.direction == Qt.LeftToRight:
arrow.translate(-2, 1)
else:
arrow.translate(+2, 1)
pen_thickness = 1.6
painter.setRenderHint(QPainter.Antialiasing, True)
painter.translate(arrow_rect.center())
painter.translate(0, +1)
painter.setPen(
QPen(self.calc_light_color(background_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
)
painter.drawPolyline(arrow)
painter.translate(0, -1)
painter.setPen(
QPen(self.deco_color(background_color, text_color), pen_thickness, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
)
painter.drawPolyline(arrow)
painter.restore()