Swipe Gesture not identified in embedded target



  • Hello Everyone!

    My apologies if I am repeating this question in Qt Project Forum. I did a search but I did not get the best answers.

    Here is my problem.

    In my ARM based Embedded Target, I am trying to implement swipe gesture to switch between tabs.

    Embedded Target has LCD which is capable only for single-touch. It doesn't support multi-touch.
    This would be my first question. Can I implement Swipe with single touch LCD? My assumption is that, it is possible. Please clarify.

    And this is what I have tried.

    @
    SimpleGesture::SimpleGesture(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::SimpleGesture)
    {
    ui->setupUi(this);
    setAttribute(Qt::WA_AcceptTouchEvents);
    grabGesture(Qt::SwipeGesture);
    }

    SimpleGesture::~SimpleGesture()
    {
    delete ui;
    }

    bool SimpleGesture::event(QEvent event)
    {
    if (event->type() == QEvent::Gesture)
    {
    qDebug() << "Gesture Identifed";
    return gestureEvent(static_cast<QGestureEvent
    >(event));
    }
    return QWidget::event(event);
    }

    bool SimpleGesture::gestureEvent(QGestureEvent *event)
    {
    if (QGesture *swipe = event->gesture(Qt::SwipeGesture))
    swipeTriggered(static_cast<QSwipeGesture *>(swipe));
    return true;
    }

    void SimpleGesture::swipeTriggered(QSwipeGesture *gesture)
    {
    if (gesture->state() == Qt::GestureFinished) {
    if (gesture->horizontalDirection() == QSwipeGesture::Left)
    {
    QMessageBox::information(this, "Swipe", "Swiped Left", QMessageBox::Ok);
    qDebug() << "Swipe Left";
    }
    else if (gesture->horizontalDirection() == QSwipeGesture::Right)
    {
    QMessageBox::information(this, "Swipe", "Swiped Right", QMessageBox::Ok);
    qDebug() << "Swipe Right";
    }
    else if (gesture->horizontalDirection() == QSwipeGesture::Up)
    {
    QMessageBox::information(this, "Swipe", "Swiped Up", QMessageBox::Ok);
    qDebug() << "Swipe Up";
    }
    else if (gesture->horizontalDirection() == QSwipeGesture::Down)
    {
    QMessageBox::information(this, "Swipe", "Swiped Down", QMessageBox::Ok);
    qDebug() << "Swipe Down";
    }
    update();
    }
    }
    @

    With the above code,
    @
    qDebug() << "Gesture Identifed";
    @
    was never printed.

    I tried to print the meta data to know the name of the events that were occuring.

    @
    "MouseButtonPress"
    "MouseMove"
    "HoverMove"
    "MouseButtonRelease"
    @

    It was never a gesture event. It was always mouse events.

    Why touch events are not recognized?

    What should I do to identify the touch events?

    Please help me out.

    Please let me know if you need any more information.

    Thank for the excellent support!

    --Kumara



  • Team,

    Any thoughts for the problem stated above?

    (I think people have been gone for Christmas and New Year Holidays. Just wanted to see if anyone working today ;) )



  • Hello!

    Finally, I got "swipe" working in my embedded target.

    As I mentioned in the previous posts, My application does not receive swipe gesture. I can get only mouse button press, release, hover events.

    Later to that, I had implemented custom gesture recognizer that uses mouse press, release along with the distance swiped. With all these, I could get the swipe working in my embedded target.

    Still, why am I not receiving touch events is still a mystery. But the functionality is achieved.

    I would like to keep this post open to get the opinion from experts.

    Thanks.


  • Lifetime Qt Champion

    Hi,

    What are you using as mouse input ? tslib ?



  • Hi Sam,

    Sorry for quite late response. Am using tslib.


  • Lifetime Qt Champion

    Ok and which version of Qt ?



  • Sam,

    Am using Qt version 4.8



  • Swipe requires TouchEvents to come. If you are using tslib and embedded Qt, it generates the QMouseEvents. Since it comes as mouse event, Gestures are not recongnized. You have to do some other mechanism to get the swipe gestures :)



  • Hi Dheerendra,

    Thanks for the reply!

    As you mentioned, thats the case exactly. I get QMouseEvents. With the mouse events, am able to use them to get Swipe Feature. So, my requirement has met. But, It was out of curiosity, to build the "mechanism" to get QTouchEvents and the swipe gestures :)

    Thank you!

    --Kumara



  • Sorry if this is a double post (I clicked Submit and all I wrote disappeared).

    My situation is nearly the same as yours, kumararajas: embedded, Qt 4.8, tslib, and wanting gestures.

    My tslib seems to be installed just fine, as well as the underlying drivers, because ts_print works as expected.
    Values look sane, and calibration worked, too.

    In my case, I want the standard gesture QSwipeGesture from the Qt recognizer, not my own gesture or recognizer.
    I added my debug output, and it looks like tslib is simply handing off ordinary mouse events,
    so the recognizer is ignoring them. As Dheerendra said, the recognizer wants TouchEvents, like TouchBegin.

    My question is, can a Qt guru confirm that Qt's tslib support can produce gestures? I really, really hope so -- I need this.

    Peter



  • Hi Peter,

    That's a nice summary.

    Partially, I might try to answer you. But, the experts can correct me.

    First of all, tslib - touch screen library, is not from Qt. Its a third party guy who made this library. Can be of many reasons for why "tslib" is so widely used. (One reason I think is, in the initial stage, only "tslib" was present to support touch screen display.

    I don't know, what are other libraries that produces touch events.

    Also, having resistive touch, there is no fun in look for "pan, zoom, pinch" gestures (In my case).



  • Thanks, kumararajas. I was hoping the QWSTslibMouseHandler class was designed for this, since that is part of Qt and understands tslib communication. But reading through the source, my fear is that the class is intended to dumb down the touch screen, and only emulate a mouse.



  • Donjuedo,

    QWSTslibMouseHandler class was there in Qt version 4.1. But, I think, this has been removed in the later versions. (That's what I read from the source "QWSTslibMouseHandler":http://doc.qt.digia.com/4.1/qwstslibmousehandler.html)

    If I refer the documentation "Qt Gui":http://qt-project.org/doc/qt-4.8/qtgui.html, i dont see the library that you specified.

    I can see QWSMouseHandler, which is meant for different purpose. You can find the documentation here "QWSMouseHandler":http://qt-project.org/doc/qt-4.8/qwsmousehandler.html#details


Log in to reply
 

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