c++qtinputkeyeventqkeyevent

Generate a keyPressEvent/Input


I need to generate an input of my keyboard, because I have an event attached to it. I tried to call this but without success:

keyPressEvent(Qt::Key_Delete);

Is there a way to generate this keyPressEvent ?


Solution

  • You might like to use a QkeyEvent.

    Are you using Qt4 or Qt5?

    Have a look at this:

    https://stackoverflow.com/a/2035547/3751213

    It might help.

    Or, if you are using linux then xte would be great. It is included in xautomation.

    xte 'key Delete'
    

    Look here: http://linux.die.net/man/1/xte