Thanks for the important tips, I wasn’t aware of any of them! I implemented all of them.
Unfortunately it is still selecting based on boundingRect. Any other thoughts? > On Jun 25, 2017, at 5:00 PM, Christian Gagneraud <[email protected]> wrote: > > On 26 June 2017 at 05:10, Patrick Stinson <[email protected] > <mailto:[email protected]>> wrote: >> >> Hi there! >> >> I have a simple QGraphicsItem which draws the left, bottom, and right >> borders of it’s bounding rect. I am painting the item by creating a >> QGraphicsPath from top-left => bottom-left => bottom-right =>? top-right. >> >> I have reimplemented shape() to return this path, but the view is still >> using the item’s bounding rect to select. I have tested this by dragging my >> selection marquee down through the top border of the item. I tried >> re-tracing the QPainterPath back to the beginning in case it was >> automatically closing it from top-right to top-left, but it didn’t help. >> >> Is there something else that needs to happen to get the view to honor >> shape()? >> >> See code and screenshot below. >> >> Thanks! >> -Patrick >> >> class Marriage(QGraphicsItem, util.Debug): >> >> def __init__(self, a, b): >> super().__init__() >> global last_id >> self.id = last_id = last_id + 1 >> self.setFlag(QGraphicsItem.ItemIsSelectable, True) >> self.path = QPainterPath() >> self.pen = util.PEN >> self.people = [a, b] >> self.children = [] >> self.hover = False # highlight >> self.update() >> >> def boundingRect(self): >> return self.shape().boundingRect() >> >> def shape(self): >> return self.path >> >> >> >> def update(self, *args): > > > BTW, update() is not a virtual method, you should instead implement a > custom function, say updateShape() in which you first call > prepareGeometryChange(). No need to call update(). > > Chris
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
