Important: Please read the Qt Code of Conduct -

[Solved]How to receive QGestureEvent in parent widget?

  • QT version: 4.8.4

    My Application Brief Introduction:
    In the most parent widget I set grabGesture(), and I want process several types of QGesture in its virtual function QWidget::event(). sometimes I can receive that message. But sometimes, when I touch in a QGraphicsScene, I found such error prompt:
    "QGestureManager::deliverEvent: could not find the target for gesture".

    Here is my question: If I touched in a QGraphicsItem In a QGraphicsScene, or I just touched in QGrahicsScene, wether or not the event will be auto transfer to parent QWidget? I do need such auto transfer progress. How can I do?

    How to eliminate that error message?

  • Moderators

    The event gets delivered to the QGraphicsView (or it's viewport) which then forwards it to the items in your scene. If the event isn't handled (accepted) event propagation takes place. Meaning the event will be propagated to the graphics views parent, and so on...

    AFAIK QGraphicsItems can't receive touch-/gesture events (unless they are QGraphicsObjects).
    I think you will have to do the logic (determining the affected QGraphicsItems, perform the desired actions, etc.) by yourself.

    I think you receive the warning because there is just no receiver for the gesture event...

  • Can widget or a graphicsView filter some gesture away?(stop event progagating)
    If it occurs, which condition can cause that?
    I just cannot locate that filter widget(or graphicsItem).

  • Moderators

    not by default...only if you have implement it.
    Did you call grabGesture() on the qgraphicsview?

  • No, I only capture gesture at parent most widget. so that's the problem?

    Btw, I read QGestureEvent's document, and found such information:
    when event type is "QEvent::GestureOverride" , the gesture event is ignored by default. and when type is "QEvent::Gesture", the gesture event is acceptd by default. so is that means if I manually set QGestureEvent's type to "GestureOverride", the Gesture will automatic propagating to parent widget?

    because of using muti-touch, the gesture is designed by myself. but I still can't find a interface to set QEvent:type() to "QEvent::GestureOverride".

    grabGesture() in every widgets seem's too complex and inconvenient.

  • I finally found the reason. the error msg is coming from the coordinate value, in derived QGestureRecognizer, I miss using the widget base coordinate value, not the global coordinate values. And the main widget is fixed at screen center. so when I operate in the upper or left zone of widget. the gestureRecognizer thinks it's beyond the main window, so display that error msg.

    coordinate is very important.

  • Moderators never mentioned that you derived QGestureRecognizer until the last post.
    How should anybody be able to help you looking for the reason of the problem, when you leave out such important information?

Log in to reply