Qt equivalent for SendInput from WinAPI



  • I would like to know if there's something equivalent in QT of the Windows API "SendInput" to put some stuff in keyboard buffer?
    We would like to keep our code as portable as possible.

    As far as i've seen, there's a QKeyEvent and postEvent, but it's used to insert "Inputs" in the QT application only (not globally just like Windows does).

    I would like to be able to send keyboard inputs to the application running on top. Notepad for example.

    Thanks



  • What you are trying to do is platform specific. Within Qt as you said you can post/send QKeyEvent but those can only be handled by Qt. Whenever Qt receives native events from the system, it translates them in those Qt specific events, ensuring portability within Qt. All you have to do to port Qt after that is to properly map the native system events to Qt specifc events.
    What you want to do is the opposite, generate Qt specific events and forward them up to the system. I don't know of any crossplatform way of doing that, and especially not in Qt.



  • Thanks for that answer rcari. That would have been nice if Qt was able to do that. I just wanted to make sure that i didn't missed anything in Qt documentation. I know it's quite extensive and i certainly didn't read the whole documentation.


Log in to reply
 

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