How to simulate touch event in Qt 3.1.2



  • 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!!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Just to be sure, is the number really 3.1.2 ?

    What exactly would you like to automate ?



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


  • Lifetime Qt Champion

    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.



  • 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?


  • Lifetime Qt Champion

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

    Also how are you starting both your applications ?



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


  • Lifetime Qt Champion

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



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


Log in to reply
 

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