Please nominate your Qt Champions for 2021!

How to emulate a mouse?

  • Hi..
    Is there a method in Qt to emulate a mouse action?
    I will try to make a free hand input using input coordinates. The input is a point but continuesly change. I assume like using a mouse for freehand drawing in paint program but the source coordinates is from my input device. After that I will make a display of that path too. Any suggestion or advice?
    Thank you in advance.

  • Moderators

    If you just want to move the cursor then take a look at QCursor::setPos().
    If you want something more like faking mouse clicks, moves, etc. then you can use QCoreApplication::sendEvent() or QCoreApplication::postEvent() and feed it with your artificial events.

  • I'm not quite sure what you are trying to do, but QTest can emulate user input (like Mouse).

Log in to reply