本文整理汇总了Python中AnyQt.QtGui.QPainterPath.boundingRect方法的典型用法代码示例。如果您正苦于以下问题:Python QPainterPath.boundingRect方法的具体用法?Python QPainterPath.boundingRect怎么用?Python QPainterPath.boundingRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QPainterPath
的用法示例。
在下文中一共展示了QPainterPath.boundingRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_graphicspathobject
# 需要导入模块: from AnyQt.QtGui import QPainterPath [as 别名]
# 或者: from AnyQt.QtGui.QPainterPath import boundingRect [as 别名]
def test_graphicspathobject(self):
obj = GraphicsPathObject()
path = QPainterPath()
obj.setFlag(GraphicsPathObject.ItemIsMovable)
path.addEllipse(20, 20, 50, 50)
obj.setPath(path)
self.assertEqual(obj.path(), path)
self.assertTrue(obj.path() is not path,
msg="setPath stores the path not a copy")
brect = obj.boundingRect()
self.assertTrue(brect.contains(path.boundingRect()))
with self.assertRaises(TypeError):
obj.setPath("This is not a path")
brush = QBrush(QColor("#ffbb11"))
obj.setBrush(brush)
self.assertEqual(obj.brush(), brush)
self.assertTrue(obj.brush() is not brush,
"setBrush stores the brush not a copy")
pen = QPen(QColor("#FFFFFF"), 1.4)
obj.setPen(pen)
self.assertEqual(obj.pen(), pen)
self.assertTrue(obj.pen() is not pen,
"setPen stores the pen not a copy")
brect = obj.boundingRect()
self.assertGreaterEqual(area(brect), (50 + 1.4 * 2) ** 2)
self.assertIsInstance(obj.shape(), QPainterPath)
positions = []
obj.positionChanged[QPointF].connect(positions.append)
pos = QPointF(10, 10)
obj.setPos(pos)
self.assertEqual(positions, [pos])
self.scene.addItem(obj)
self.view.show()
self.app.exec_()