[Interest] QGraphicsView selection not honoring QGraphicsItem::shape?
chgans at gmail.com
Mon Jun 26 05:07:20 CEST 2017
On 26 June 2017 at 14:58, Patrick Stinson <patrickkidd at gmail.com> wrote:
>> On Jun 25, 2017, at 4:51 PM, Christian Gagneraud <chgans at gmail.com> wrote:
>> On 26 June 2017 at 05:10, Patrick Stinson <patrickkidd at gmail.com> wrote:
>>> def update(self, *args):
>>> if None in self.people:
>> you're missing a call to prepareGeometryChange()
>>> a = self.mapToScene(self.people.bottomCenterScene())
>>> b = self.mapToScene(self.people.bottomCenterScene())
>> The path should be in (this) item coordinates, not scene coordinates.
> This item will always be top-level so the coordinates will match the scene.
In this case, you need to make sure that all your items are
positionned at the scene origin too.
> But for cleanliness’ sake, how do you convert from scene coordinates to item coordinates? I don’t see a method for that.
a = mapFromItem(otherItem, otherItem.pointInLocalCoordinate())
b = mapFromScene(pointInSceneCoordiante())
QGI has a lot of mapTo/From, .... More that you will ever need! ;)
>> 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.
More information about the Interest