Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Swipe Gesture not identified in embedded target

Swipe Gesture not identified in embedded target

Scheduled Pinned Locked Moved Mobile and Embedded
13 Posts 4 Posters 4.8k Views
  • 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.
  • K Offline
    K Offline
    kumararajas
    wrote on last edited by
    #1

    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

    --Kumar

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kumararajas
      wrote on last edited by
      #2

      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 ;) )

      --Kumar

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

        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.

        --Kumar

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          What are you using as mouse input ? tslib ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kumararajas
            wrote on last edited by
            #5

            Hi Sam,

            Sorry for quite late response. Am using tslib.

            --Kumar

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Ok and which version of Qt ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kumararajas
                wrote on last edited by
                #7

                Sam,

                Am using Qt version 4.8

                --Kumar

                1 Reply Last reply
                0
                • dheerendraD Offline
                  dheerendraD Offline
                  dheerendra
                  Qt Champions 2022
                  wrote on last edited by
                  #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 :)

                  Dheerendra
                  @Community Service
                  Certified Qt Specialist
                  http://www.pthinks.com

                  1 Reply Last reply
                  2
                  • K Offline
                    K Offline
                    kumararajas
                    wrote on last edited by
                    #9

                    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

                    --Kumar

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      donjuedo
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        kumararajas
                        wrote on last edited by
                        #11

                        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).

                        --Kumar

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          donjuedo
                          wrote on last edited by
                          #12

                          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.

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            kumararajas
                            wrote on last edited by
                            #13

                            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

                            --Kumar

                            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