本页内容

EnterKeyAction QML Type

提供用于自定义回车键的附加属性。更多...

Import Statement: import QtQuick.VirtualKeyboard

附加属性

详细说明

EnterKeyAction 类型提供了附加属性,用于自定义键盘上的回车键。

必须在接收输入焦点的控件内部直接使用 EnterKeyAction,例如:TextInput 。

例如:

TextInput {
    id: myInput
    EnterKeyAction.enabled: myInput.text.length > 0 || myInput.inputMethodComposing
    EnterKeyAction.label: "Next"
    Keys.onReleased: {
        if (event.key === Qt.Key_Return) {
            // execute action
        }
    }
}

附加属性文档

EnterKeyAction.actionId : int [attached]

设置虚拟键盘中“回车键”的操作 ID。当设置了操作 ID 后,它将优先于标签,并设置“回车键”的图标。

  • EnterKeyAction.None 未定义操作。
  • EnterKeyAction.Go 该操作执行“前往”操作。例如,将用户引导至输入的 URL。
  • EnterKeyAction.Search 该操作执行搜索操作。
  • EnterKeyAction.Send 该操作会发送输入的文本。
  • EnterKeyAction.Next 该操作将输入焦点移至下一个接受文本输入的字段。
  • EnterKeyAction.Done 与EnterKeyAction.Next 相同,只是此时所有文本输入操作均已完成。

EnterKeyAction.enabled : bool [attached]

启用或禁用虚拟键盘中的回车键。

EnterKeyAction.label : string [attached]

设置虚拟键盘中“回车键”的标签。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.