Important: Please read the Qt Code of Conduct -

[Solved] No Cursor KeyEvent to WebView

  • Hi

    I am getting key events by an external interface that need to be carried out by a WebView. This works perfect for Key_Tab and Key_Backtab for instance, but not for the Cursor Keys Key_Left/Up/Down/Right.
    I am using the following code and the cursor keys are not accepted.

    @QKeyEvent key(QEvent::KeyPress, datastring.section(' ', 1, 1).toULong(), Qt::NoModifier);
    QApplication::sendEvent(ui->webGUI, &key);
    if (key.isAccepted()) port->write(data);

    What am I doing wrong, or how do I get the WebView to react on the Cursor Keycodes the same it does on the Tab key?


  • Update:
    I didn't realize that the cursor keys have a KeyRelease event only. So I now always send a KeyPress and a KeyRelease event and it works.

Log in to reply