Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. Qt Contribution
  4. How to simulate touch event in Qt 3.1.2
QtWS25 Last Chance

How to simulate touch event in Qt 3.1.2

Scheduled Pinned Locked Moved Qt Contribution
9 Posts 3 Posters 5.2k 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.
  • S Offline
    S Offline
    Sujee S
    wrote on last edited by
    #1

    Hello,
    We have an UI application running in an embedded system which receives touch screen events. I would like to automate touch events in my application using another simple qt application which receives X and Y co-ordinates from the user.

    Kindly help with some reference documents.

    We tried the below code, no failures observed but it doesnt simulate the touch event.

                 @QApplication a(argc, argv,QApplication::GuiServer);
    
                QWSTslibMouseHandler *ptr;
                ptr = (QWSTslibMouseHandler*)QWSServer::mouseHandler() ;
                int x,y;
                printf("\n Enter X co-ordinate :");
                scanf("%d",&x);
                printf("\n Enter Y co-ordinate :");
                scanf("%d",&y);
                QPoint q;
                q.setX(x);
                q.setY(y);
                QPoint mousePos=q;
                printf("\nBefore Emit..");
                fflush(stdout);
                emit ptr->mouseChanged(mousePos,Qt::LeftButton);
                printf("\nAfter Emit..");
                fflush(stdout);@
    

    Thanks in advance!!

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

      Hi and welcome to devnet,

      Just to be sure, is the number really 3.1.2 ?

      What exactly would you like to automate ?

      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
      • S Offline
        S Offline
        Sujee S
        wrote on last edited by
        #3

        Hi,

        Sorry we are using version 3.0.3.
        We would like to automate touch events for our embedded system which in turn is considered as a mouse click event by our QT application.

        To be clear, I have pasted the below lines from design documentation.

        "QWSTslibMouseHandler opens touch screen device and then read samples from the device. These samples are transformed to screen coordinates and then passed to mouseChanged function for further actions.These mouse events are handled by QT application."

        Here I want to send the samples instead of reading from touch screen device.

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

          3.0.3 ? Are you aware that's a release that is about 13 years old ?

          Anyway, the code you show seems a bit light for what you want to do, e.g. the event loop doesn't seem to ever run.

          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
          • A Offline
            A Offline
            ArunkumarRavi
            wrote on last edited by
            #5

            Hi SGaist,
            Myself and the author of this post Sujee S are project mates.So i too would like to share my thoughts here as we both of us are looking into this feasibility for touch screen simulation.
            As per your quote, regarding the QT version.. Yes, it an very old QT we are using.The device we are using is a legacy embedded device years back... Because of the old version of Qt we are facing problems is simulating this events..
            Another question i would ask is.. Is it possible to simulate in Qt 3.0.3 ? or it needs to be done by injecting into the touchscreen driver ?

            And which event loop in the above code would never run? you mean the emit ptr->mouseChanged(mousePos,Qt::LeftButton); code line?

            Also can you help us in providing some example code links?

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

              Qt's event loop is never running since you never call a.exec().

              Also how are you starting both your applications ?

              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
              • A Offline
                A Offline
                ArunkumarRavi
                wrote on last edited by
                #7

                Hi SGaist,
                Sorry for the delayed reply..
                I would like to explain the exact scenario of our requirement.. We have already designed an embedded system which runs with a UI process(Lets assume as P1) waiting for inputs frm the user through touch..
                Here we would like to create a another separate process(assume P2) which shall prompt for the co-oridanates at which the touch event needs to be simulated.. this simulated touch event should make the existing UI process (process P1) to process the event loop.. its like a touch event emiited by process P2 should make Process P1 to catch and process it.. I believe the QApplication is different for both these processes P1 and P2..
                So is it possible to simulate a system wide touch (emit ) event by P2 or is it within application specific ?
                We have released this requirement in an QNX OS environment using the PhEmit() function.. Reference at http://www.qnx.com/developers/docs/6.4.1/photon/lib_ref/ph/phemit.html which generates/emits an system wide event as described and this event can be caught by the ui process in qnx.. So currently we are looking similar/any way to simulate in this version of qt.. Pls do share ur thoughts..

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

                  Never tried it but since you are using qws you should be able to achieve that using QWSInputMethod::sendEvent in your secondary app

                  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
                  • A Offline
                    A Offline
                    ArunkumarRavi
                    wrote on last edited by
                    #9

                    Hi SGaist,
                    Thanks for your reply.. will try it out and let u know.

                    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