Simulating mouse using a joystick



  • I'm a QT newbie working on an embedded application that has no mouse, we need to use a joystick instead.

    I am attempting to simulate mouse clicks using QT Creator (on my desktop) using this example code before trying it in my embedded app. This code is connected to a text box that I type into while hovering the mouse over a button. It appears the events are being sent but do not trigger a button click when hovering the mouse over this button. Any suggestions? Thanks!

    @void MouseTest::test()
    {
    // Get cursor position
    point=cursor.pos();

    // Create mouse button "press" event and send it to the application
    QMouseEvent *ePress = new QMouseEvent(QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::LeftButton, 0);
    QApplication::sendEvent(qApp->activeWindow(), ePress);
    
    // Create mouse button "release" event and send it to the application
    QMouseEvent *eRelease = new QMouseEvent(QEvent::MouseButtonRelease, point, Qt::LeftButton, Qt::LeftButton, 0);
    QApplication::sendEvent(qApp->activeWindow(), eRelease);
    

    }@


Log in to reply
 

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