android - TextField 文本字段在 QML 上不返回值 | QT 5.12

标签 android qt android-ndk qml textfield

我需要帮助。 所以这是我的代码:

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”。

问题看TextField 没有得到用户插入的值。我在屏幕上的 TextField 上插入了 123456,然后单击 Button:

MouseArea {
    anchors.fill: parent
    onClicked: {
        var test = passwordIDText.text;
        //passwordIDText.text is empty wtf !??

    }
}

所以有人有同样的问题?在较旧的 Android 版本上,TextField 可以正常工作。

我的配置:

enter image description here

最佳答案

我相信这可能是一个类似于 this question 的问题,与您需要访问时未提交的预测文本有关。

尝试使用 passwordIDText.displayText 而不是 passwordIDText.text

或者,您可以关闭预测文本输入:

inputMethodHints: Qt.ImhNoPredictiveText

关于android - TextField 文本字段在 QML 上不返回值 | QT 5.12,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56649760/

相关文章:

c++ - Windows GDI 打印机错误 StartDocPrinter

android-ndk - 使用Gradle在Windows上编译NDK源代码时的"No rule to make target"

android - 重新打开 sqlcipher DB 时创建表 android_metadata 失败

qt - QML ItemDelegate 突出显示的属性不起作用

c++ - 如何在菜单栏中添加单选按钮,qt 5 c++

android - 如何使用 NativeActivity 写入内部存储文件系统?

android-ndk - Alljoyn android 事件和操作示例不工作

Android:如何将图像稍微定位在 View 之外

android - 创建连接到数据库的成员(member)应用程序,我应该学习什么?

java - Android 应用程序崩溃和 ListView 不显示