Solved onTextChanged signal on Android
-
Hello,
I have a little problem with a qml box under Android (Qt 5.15.0)
When I type text in this TextInput (see below), a TextChanged signal is only emitted when I press ENTER on the Android virtual keyboard. I would like the signal to be sent for each new letter I type. This would allow me to make suggestions during text input.How can I do this?
Under Windows and Linux, everything works well this way
Thanks !
TextInput { id: textInput y: 25 height: 30 color: "#ffffff" text: anchorselection.search anchors.right: busyIndicator.left anchors.rightMargin: 10 anchors.left: image3.right anchors.leftMargin: 10 anchors.bottom: parent.bottom anchors.bottomMargin: 0 activeFocusOnPress: anchorselection.Android focus: !anchorselection.Android cursorVisible: true font.family: "Tahoma" font.pixelSize: 20 Rectangle { color: "#1e252f" anchors.fill: parent z: -1 } inputMethodHints: Qt.ImhNoPredictiveText onTextChanged: { if (anchorselection.search !== textInput.text) anchorselection.checkPost_Search(textInput.text) } }
-
@Francky033
Have you triedonTextEdited
? -
Si. Yes, it gives the same result...
-
@Francky033 on Android and iOS you have to check if displayText changed to get each entered letter. getting text changed you know user hits ENTER
I'm using onDisplayTextChanged for all my search fields
curios: on macOS you get text changed for each letter -
Thank you eekscorner!
Changing onTextChanged to onDisplayTextChanged effectively sends a signal when typing on the keyboard.
The problem is that textInput.text is equal to "" until the user presses ENTER or SPACE.
How do I retrieve text from textInput while typing?
Thanks !
-
@Francky033 try to set textInput.text from onDisplayTextChanged
-
After these modifications, everything works properly!
Thank you all!
TextInput { id: textInput y: 25 height: 30 color: "#ffffff" anchors.right: busyIndicator.left anchors.rightMargin: 10 anchors.left: image3.right anchors.leftMargin: 10 anchors.bottom: parent.bottom anchors.bottomMargin: 0 activeFocusOnPress: anchorselection.Android focus: !anchorselection.Android cursorVisible: true font.family: "Tahoma" font.pixelSize: 20 Rectangle { color: "#1e252f" anchors.fill: parent z: -1 } inputMethodHints: Qt.ImhNoPredictiveText onDisplayTextChanged: { if (anchorselection.search !== textInput.displayText) anchorselection.checkPost_Search( textInput.displayText) } }