Qml TextEdit Custom key event not processed properly
Solved
QML and Qt Quick
-
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 Item{ function processSpace(event){ event.accepted = true console.log(xTextEdit.text) } TextEdit{ id: xTextEdit height: parent.height width: parent.width Keys.onSpacePressed: processSpace(event) } }