[SOLVED]Problem with QTouchEvent



  • Hiya there,

    Test is a QDeclarativeItem, i'm successfully getting QTouchEvents but my QTouchEvents also translated to QGraphicsSceneMouseEvent automatically that i don't wanna. I read in doc as something like that ;

    "By default, QWidget::event() translates the first non-primary touch point in a QTouchEvent into a QMouseEvent."
    I wanna disable that behaviour, but there is no clue. Also my TouchUpdate events translated into MouseMoveEvent when i saw that i was like what the heck is going on there, here is my piece of code how i'm trying to catch events.

    @
    bool Test::sceneEvent(QEvent event)
    {
    if (m_isLocked) {
    event->ignore();
    return false;
    }
    if (event->type() == QEvent::Gesture) {
    return gestureEvent(static_cast<QGestureEvent
    >(event));
    }
    else if (event->type() == QEvent::TouchBegin) {
    return touchBeginEvent(static_cast<QTouchEvent*>(event));
    }
    else if (event->type() == QEvent::TouchUpdate) {
    return touchUpdateEvent(static_cast<QTouchEvent*>(event));
    }
    else if (event->type() == QEvent::TouchEnd) {
    return touchEndEvent(static_cast<QTouchEvent*>(event));
    }

    return QDeclarativeItem::sceneEvent(event);
    

    }

    bool Test::touchBeginEvent(QTouchEvent *event)
    {
    qDebug() << "TB" << event;
    event->accept();
    return true;
    }

    bool Test::touchUpdateEvent(QTouchEvent *event)
    {
    qDebug() << "TU" << event;
    return true;
    }

    void Test::mousePressEvent(QGraphicsSceneMouseEvent *event)
    {
    qDebug() << "MP" << event;
    }

    void Test::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
    {
    qDebug() << "MM" << event;
    }
    @

    When i touch to screen i see in output something like ;

    @
    TB
    TU
    TU
    MP <.< it translate touch point to MousePress
    TU
    MM <.< it translate touch point to to MouseMove
    MM <.<
    TU
    MM <.<
    TU
    TU
    MM <.<
    ...
    @

    I hope i can explain my problem, is there any clue how can i disable that automatic translation from QTouchEvent to mouse event.

    Regards,
    Abel



  • After i read QTouchEvent document deeply i figured out how my windowing system works. I modified my functions as it must so it works fine.

    Mouse Events and the Primary Touch Point
    QTouchEvent delivery is independent from that of QMouseEvent. On some windowing systems, mouse events are also sent for the primary touch point. This means it is possible for your widget to receive both QTouchEvent and QMouseEvent for the same user interaction point. You can use the QTouchEvent::TouchPoint::isPrimary() function to identify the primary touch point.



  • Hey,

    maybe this thread is a little bit old, but currently i am faced with the same problem. I also want to disable the automatic translation of the first non-primary touchpoint into a mouse event? How did you achived that? What do you mean with "i figured out how my windowing system works"

    Any help would be greatly appreciated


Log in to reply
 

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