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. Simulating mouse using a joystick
Forum Updated to NodeBB v4.3 + New Features

Simulating mouse using a joystick

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 1.3k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    Briman
    wrote on last edited by
    #1

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

    }@

    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