[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] Handling QGraphicsItem snapping outside of itemChange
From: Devan Richmond <devan.richmond () gmail ! com>
Date: 2015-02-25 9:45:24
Message-ID: CAJuBzCaTQLcSgH_38Cx+1JviJ40tni1Dfe+OXieGUd_AFNYtRQ () mail ! gmail ! com
[Download RAW message or body]
Hi,
I've been trying to create a snap to grid type system for QGraphicsScene and
it seems that most solutions rely on altering the item itself in it's itemChange
method. The problem I have with that solution is that it will also affect
what happens when you use QGraphicsItem::setPos
My ideal solution would decouple the items from any notion of grid snapping such
that the QGraphicsScene deals exclusively with the snapping.
# QGraphicsScene::mouseMoveEvent
def mouseMoveEvent(self, event):
# snapping logic
event.setScenePos(QtCore.QPointF(x, y))
super().mouseMoveEvent(event)
I know that QGraphicsSceneMouseEvent::setScenePos is internal and not public but
it demonstrates what type of functionality I'm aiming for. Similarly, the
constructor is also internal so I can't subclass or create a new instance to
inject my own event.
A kick in the right direction about how to implement something like this without
using undocumented functions would be much appreciated.
Thanks
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic