TextField文本字段不会在QML上返回值|QT 5.12 [英] TextField text field doesn't return value on QML | QT 5.12
问题描述
我需要帮助.这是我的代码:
i need an help. So this is my code:
TextField {
id: passwordIDText
placeholderText: "Insert text..."
color: "Black"
font.bold: true
font.pixelSize: 21
anchors.top: parent.top
anchors.topMargin: parent.height / 10
anchors.horizontalCenter: parent.horizontalCenter
text: "aaa"
}
我使用的是Android 8(P20),QT 12.4,Android NDK 20和Android SDK 28.因此,当我单击android屏幕上的按钮(我正在使用20进行测试)时,在调试中,为了获取passwordIDText.text,该字段为空,为什么?但是,如果我将文本设置为:"aaa"硬编码,则会得到passwordIDText.text ="aaa".
I use Android 8 (P20), QT 12.4, Android NDK 20 and Android SDK 28. So when i click the button on the android screen (i'm using 20 to testing), in debug, for get the passwordIDText.text, the field is empty, why ?? But if i set text: "aaa" hard coded, i get passwordIDText.text = "aaa".
问题外观TextField无法获得用户插入的值.我在屏幕上的TextField上插入了123456,然后单击Button:
The problem look TextField don't get the value inserted by the user. I've inserted 123456 on TextField on screen and click on Button:
MouseArea {
anchors.fill: parent
onClicked: {
var test = passwordIDText.text;
//passwordIDText.text is empty wtf !??
}
}
那么有人有同样的问题吗?在较旧的Android版本上,TextField可以正常工作.
So someone have the same problem ? On the older Android version TextField works correctly.
我的配置:
推荐答案
I believe it might be an issue similar to this question, related to predictive text not being committed at the time you need to access it.
尝试使用 passwordIDText.displayText
而不是 passwordIDText.text
.
或者,您可以拒绝预想输入法:
Alternatively you can turn down predictive text input:
inputMethodHints:Qt.ImhNoPredictiveText
这篇关于TextField文本字段不会在QML上返回值|QT 5.12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!