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
Qt Code:
  1. def updateTransform(self):
  2. self.dx = self.boundingRect().width()/self.charPath.boundingRect().width()
  3. self.dy = self.boundingRect().height()/self.charPath.boundingRect().height()
  4. transform = self.transform()
  5. transform.scale(self.dx,self.dy)
  6. self.setTransform(transform)
  7. self.prepareGeometryChange()
  8. # here I want to set the new boundingRect
  10. def boundingRect(self):
  11. return self.rect
To copy to clipboard, switch view to plain text mode