royt
1st July 2012, 16:15
I noticed that on Windows and Mac OS X 10.6, when dragging a QGraphicsItem out of the current QGraphicsView, but still in the QGraphicsScene, the code flow is not same. And I think there may be something wrong on OS X. In file "QGraphicsScene.cpp", there is a function:
void QGraphicsScenePrivate::sendMouseEvent(QGraphicsSce neMouseEvent *mouseEvent)
{
if (mouseEvent->button() == 0 && mouseEvent->buttons() == 0 && lastMouseGrabberItemHasImplicitMouseGrab) {
// ### This is a temporary fix for until we get proper mouse
// grab events.
clearMouseGrabber();
return;
}
...
}
Just set a breakpoint there, on Mac OS, the if condition is true, so sendMouseEvent will return, and following code for event handling won't be executed, that will make something wrong. I think function button() should return LeftButton, that is the button pressed before dragging, but NoButton is returned. If the QGraphicsItem not dragged out of the QGraphicsView, all things are right.
I think maybe it's a Qt bug, who can tell me when the value for button is changed after the QGraphicsSceneMouseEvent is made (where is the related line in source code)? Thanks!
void QGraphicsScenePrivate::sendMouseEvent(QGraphicsSce neMouseEvent *mouseEvent)
{
if (mouseEvent->button() == 0 && mouseEvent->buttons() == 0 && lastMouseGrabberItemHasImplicitMouseGrab) {
// ### This is a temporary fix for until we get proper mouse
// grab events.
clearMouseGrabber();
return;
}
...
}
Just set a breakpoint there, on Mac OS, the if condition is true, so sendMouseEvent will return, and following code for event handling won't be executed, that will make something wrong. I think function button() should return LeftButton, that is the button pressed before dragging, but NoButton is returned. If the QGraphicsItem not dragged out of the QGraphicsView, all things are right.
I think maybe it's a Qt bug, who can tell me when the value for button is changed after the QGraphicsSceneMouseEvent is made (where is the related line in source code)? Thanks!