Backspace with a virtual keyboard in combination with WebView



  • Hi,

    I have written a virtyual keyboard to edit/enter text. This was not specific for WebView only but it only fails to work with WebView. It does work for instance for TextEdit.

    What already works with a WebView

    • I'm able to show and hide the virtual keyboard
    • I'm able to add (append) text.

    What doesn't work

    • removing text with the backspace button on my virtual keyboard. This does work on TextEdit {...} but not for WebView

    When I click a button the qml calls some C++ code - a qml plugin - that sends an event to the focused object.

    Code:

    @ void VirtualkeyboardKeys::keyPressed(QString character) {

    QObject* focusObject = QGuiApplication::focusObject();
    QInputMethodEvent ev;

    if (character == QString("backspace")) {
       ev.setCommitString("",-1,1);
       QCoreApplication::sendEvent(focusObject,&ev);
    } else {
          ev.setCommitString(character);
          QCoreApplication::sendEvent(focusObject,&ev);
    }
    

    }
    @

    I'm using Qt 5.2.1

    Any ideas? Thanks for the help


Log in to reply
 

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