Qml TextEdit Custom key event not processed properly

  • I wanted to add custom key events to a TextEdit. But, it seems key events are not properly processed inside TextEdit.

    For example, in the code below, I am trying to handle Space key events. Although the Space keypress is recognized by the signal handler function, the output text does not contain a space. It is the same for all other key events. How do I overcome this?

    import QtQuick 2.15
    import QtQuick.Controls 2.15
        function processSpace(event){
            event.accepted = true
            id: xTextEdit
            height: parent.height
            width: parent.width
            Keys.onSpacePressed: processSpace(event)

  • Seems like I have to write event.accepted = false and then it works

Log in to reply