Hi,
I have an item inherited from QGraphicsItem
I draw in the item (using QPainterPath)
Then I want to do 2 things:
Scale the item so that the QPainterPath boundaries will have the item size
Resize the item to the original size so that it will include only the QPainterPath
I managed to do the first mission using transform
How can I set the item's boundaries to that of the enlarged QPainterPath
def updateTransform(self):
self.dx = self.boundingRect().width()/self.charPath.boundingRect().width()
self.dy = self.boundingRect().height()/self.charPath.boundingRect().height()
transform = self.transform()
transform.scale(self.dx,self.dy)
self.setTransform(transform)
self.prepareGeometryChange()
# here I want to set the new boundingRect
def boundingRect(self):
return self.rect
def updateTransform(self):
self.dx = self.boundingRect().width()/self.charPath.boundingRect().width()
self.dy = self.boundingRect().height()/self.charPath.boundingRect().height()
transform = self.transform()
transform.scale(self.dx,self.dy)
self.setTransform(transform)
self.prepareGeometryChange()
# here I want to set the new boundingRect
def boundingRect(self):
return self.rect
To copy to clipboard, switch view to plain text mode
Bookmarks