本文整理汇总了Python中PySide.QtGui.QPainterPath.addRoundedRect方法的典型用法代码示例。如果您正苦于以下问题:Python QPainterPath.addRoundedRect方法的具体用法?Python QPainterPath.addRoundedRect怎么用?Python QPainterPath.addRoundedRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPainterPath
的用法示例。
在下文中一共展示了QPainterPath.addRoundedRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addPort
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRoundedRect [as 别名]
def addPort(self, name, isOutput = False, flags = 0, ptr = None):
port = QNEPort(self)
port.setName(name)
port.setIsOutput(isOutput)
port.setNEBlock(self)
port.setPortFlags(flags)
port.setPtr(ptr)
fontmetrics = QFontMetrics(self.scene().font());
width = fontmetrics.width(name)
height = fontmetrics.height()
if width > self.width - self.horzMargin:
self.width = width + self.horzMargin
self.height += height
path = QPainterPath()
path.addRoundedRect(-self.width/2, -self.height/2, self.width, self.height, 5, 5)
self.setPath(path)
y = -self.height / 2 + self.vertMargin + port.radius()
for port_ in self.childItems():
if port_.type() != QNEPort.Type:
continue
if port_.isOutput():
port_.setPos(self.width/2 + port.radius(), y)
else:
port_.setPos(-self.width/2 - port.radius(), y)
y += height;
return port
示例2: set_shape
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRoundedRect [as 别名]
def set_shape(self, width, height):
''' Compute the polygon to fit in width, height '''
path = QPainterPath()
path.addRoundedRect(0, 0, width, height, height / 2, height / 2)
path.moveTo(min(width / 2, height / 2), 0)
path.lineTo(min(width / 2, height / 2), height)
path.moveTo(max(width / 2, width - height / 2), 0)
path.lineTo(max(width / 2, width - height / 2), height)
self.setPath(path)
super(Start, self).set_shape(width, height)
示例3: __init__
# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addRoundedRect [as 别名]
def __init__(self, parent):
super(QNEBlock, self).__init__(parent)
path = QPainterPath()
path.addRoundedRect(-50, -15, 100, 30, 5, 5);
self.setPath(path)
self.setPen(QPen(Qt.darkGreen))
self.setBrush(Qt.green)
self.setFlag(QGraphicsItem.ItemIsMovable)
self.setFlag(QGraphicsItem.ItemIsSelectable)
self.horzMargin = 20
self.vertMargin = 5
self.width = self.horzMargin
self.height = self.vertMargin