[Interest] QGraphicsView selection not honoring QGraphicsItem::shape?

Christian Gagneraud chgans at gmail.com
Mon Jun 26 01:51:10 CEST 2017


On 26 June 2017 at 05:10, Patrick Stinson <patrickkidd at gmail.com> wrote:
>     def update(self, *args):
>         if None in self.people:
>             return

you're missing a call to prepareGeometryChange()

>         a = self.mapToScene(self.people[0].bottomCenterScene())
>         b = self.mapToScene(self.people[1].bottomCenterScene())

The path should be in (this) item coordinates, not scene coordinates.


Plus you're bounding rect should include the pen width of the path
you're drawing, eg:
halfPenWidth = self.pen.width()/2.0;
return self.path.boundingRect().adjusted(-halfPenWidth, -halfPenWidth
, halfPenWidth , halfPenWidth )

Hope this helps.

Chris



More information about the Interest mailing list