Gesture with mouse event problem



  • Hello,

    I'm using Qt 5.3 on Android.
    Problem is that mouseReleaseEvent is not generated for my QGraphicsItem when I'm using two fingers. I can replicate this with such a behaviour: Touch one finger, start swipe, touch second finger (Pinch is started), remove first finger first and then remove second - no mouseReleaseEvent on the item.
    I can see that mousePressEvent is delivered when I press first finger, no event on second finger, so I imagine that if I remove first finger first and then second - the system gets confused.
    I'm using QPinchGesture on QGraphicsView and also mousePress/Move/Release on QGraphicsScene (Can't use QPanGesture becasue it is always generated with two fingers - strange)

    Anyway I know when QPinchGesture ends

    if(pinch->state()==Qt::GestureFinished)
    

    So I could post mouseReleaseEvent to my item (it should be then forwarded to QGraphicsScene) after pinch gesture is finished, but no matter how I try It fails.
    I read that event propagation is from QGraphicsScene to the items, however in my log I can see that first items receives mouseReleaseEvent and then QGraphicsScene.
    Anyway I have tried sending to QGraphicsScene and QGraphicsItem - QApplication::sendEvent returns false If I post to QGraphicsView - result is true - but neither QGraphicsScene nor my item receives this event, generally:

    QMouseEvent event(QEvent::MouseButtonRelease,QPoint(floor->mainviewItem->boundingRect().width()/2,floor->mainviewItem->boundingRect().height()/2),Qt::LeftButton,Qt::LeftButton,Qt::NoModifier);
        bool ret=QApplication::sendEvent(floor->mainviewItem, &event);
    

    I cant send QGraphicsSceneMouseEvent but I read that if I post QMouseEvent to QGraphicsView it will be transformed to QGraphicsSceneMouseEvent and delivered to the scene, so

    QMouseEvent event(QEvent::MouseButtonRelease,QPoint(100,100),Qt::LeftButton,Qt::LeftButton,Qt::NoModifier);
        bool ret=QApplication::sendEvent(graphicsView, &event);
    

    sendEvent returns true, but I can't see the event being delivered to the scene or item.

    How to solve this issue? I would like to deliver mouseReleaseEvent to the scene after pinch is finished.

    Best Regards
    Marek


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.