I am currently trying to write a QML/C++ application for Android. Somewhere in my code, I have a class that looks like this:
class MyClass : public QObject
{
Q
As far as I understand the comments to my question, I have a few possibilities to solve this problem. The simplest one is to modify my QML item like this:
ColumnLayout {
TextField {
id: myField
placeholderText: qsTr("Enter text")
Layout.fillWidth: true
Binding {
target: myClass
property: "prop"
value: myField.displayText
}
}
If I didn't want to allow predictive text input, then I could just add the
inputMethodHints: Qt.ImhNoPredictiveText
on the TextField. In my case, I want predictive text input.
Last, I could call QInputMethod::commit() when I click the button "Done" of my application, which will commit the displayed text on Android and then use the committed text in MyClass. In this case, I should not use QML's Binding feature. Instead, I should just commit the data to Android and then communicate my QML data to myClass.
The simplest solution that best fits QML philosophy is probably to use displayText instead of text, which is the solution I am choosing.