QGraphicsItem's child item doesn't read the drag events
-
-
Items do not receive drag and drop events by default; to enable this feature, call setAcceptDrops(true).
-
This doesn't change anything,
still can't see my prints inside my drag methods. The parent is still moving.I think the key is documentation statement:
"By accepting the event, (i.e., by calling QEvent::accept(),) the item will accept drop events, in addition to receiving drag move and drag leave. Otherwise the event will be ignored and propagate to the item beneath."What I am sure about - I had implemented 2D "shape" editor myself and I had something you described and had no problem to separate child transformation from parent.
Without seen the code it is tough to provide more than general help..
-
class HandleItem(QtWidgets.QGraphicsItem): def __init__(self, parent): super(HandleItem, self).__init__(parent) self.setAcceptDrops(True) self.setAcceptHoverEvents(True) # + bounding rect() # + shape() # + paint() # + extra code def dragEnterEvent(self, event): event.accept() print 'resize start'This item is simply parent under an other one
... handleInst = HandleItem(parent=self) -
class HandleItem(QtWidgets.QGraphicsItem): def __init__(self, parent): super(HandleItem, self).__init__(parent) self.setAcceptDrops(True) self.setAcceptHoverEvents(True) # + bounding rect() # + shape() # + paint() # + extra code def dragEnterEvent(self, event): event.accept() print 'resize start'This item is simply parent under an other one
... handleInst = HandleItem(parent=self)Is parent above child?
If not I am out of guesses. In C++ it used to work. -
@Goffer I mean ZValue, but if I recall right this affect only siblings.
The only other guess I can make - problem might be related to wrong shape or bounding rectangle definition. Basically item is not found when clicked.