Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Problem with QTouchEvent
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Problem with QTouchEvent

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nightroad
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nightroad
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kinglui987
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved