InputEngine QML Type

将用户输入映射到输入法。更多

Import Statement: import QtQuick.VirtualKeyboard
In C++: QVirtualKeyboardInputEngine

属性

信号

方法

详细说明

输入引擎负责将输入事件路由到输入方法。实际的输入逻辑由输入方法实现。

输入引擎还包括默认输入法,如果活动输入法无法处理事件,默认输入法将负责默认处理。

属性文档

activeKey : int [read-only]

当前按下的键。


inputMethod : InputMethod

使用此属性可设置活动输入法,或在活动输入法发生变化时进行监控。


inputMode : int

使用此属性可获取或设置当前输入模式。InputEngine::inputModes 属性提供了当前输入法和本地的有效输入模式列表。

预定义的输入模式有

  • InputEngine.InputMode.Latin 拉丁文默认输入模式。
  • InputEngine.InputMode.Numeric 只允许数字输入。
  • InputEngine.InputMode.Dialable 只允许拨号输入。
  • InputEngine.InputMode.Pinyin 中文的拼音输入模式。
  • InputEngine.InputMode.Cangjie 仓颉中文输入模式。
  • InputEngine.InputMode.Zhuyin 中文注音输入模式。
  • InputEngine.InputMode.Hangul 韩文的韩文输入模式。
  • InputEngine.InputMode.Hiragana 日语的平假名输入模式。
  • InputEngine.InputMode.Katakana 日语片假名输入模式
  • InputEngine.InputMode.FullwidthLatin 东亚语言的全宽拉丁文输入模式。
  • InputEngine.InputMode.Greek 希腊文输入模式
  • InputEngine.InputMode.Cyrillic 西里尔输入模式
  • InputEngine.InputMode.Arabic 阿拉伯文输入模式
  • InputEngine.InputMode.Hebrew 希伯来文输入模式
  • InputEngine.InputMode.ChineseHandwriting 中文手写体
  • InputEngine.InputMode.JapaneseHandwriting 日文手写体
  • InputEngine.InputMode.KoreanHandwriting 韩文手写体
  • InputEngine.InputMode.Thai 泰文输入模式
  • InputEngine.InputMode.Stroke 中文笔画输入模式。
  • InputEngine.InputMode.Romaji 日语罗马字输入模式。
  • InputEngine.InputMode.HiraganaFlick 日文轻弹输入模式。

inputModes : list<int> [read-only]

可用输入模式列表取决于输入法和本地语言。当任何一个依赖项发生变化时,此属性都会更新。


patternRecognitionModes : list<int> [read-only, since QtQuick.VirtualKeyboard 2.0]

可用模式识别模式列表。

可能的值:

常量说明
InputEngine.PatternRecognitionMode.None模式识别不可用。
InputEngine.PatternRecognitionMode.PatternRecognitionDisabledobsolete - 请使用 代替。None
InputEngine.PatternRecognitionMode.Handwriting用于手写识别的模式识别。
InputEngine.PatternRecognitionMode.HandwritingRecoginitionobsolete - 请使用 。Handwriting

该属性在 QtQuick.VirtualKeyboard 2.0 中引入。


previousKey : int [read-only]

以前按下的键。


wordCandidateListModel : SelectionListModel [read-only]

使用该属性可访问单词候选列表的列表模型。


wordCandidateListVisibleHint : bool [read-only]

使用该属性可检查候选词列表是否应在用户界面中可见。


信号文档

void activeKeyChanged(int key)

表示活动key 已更改。

注: 相应的处理程序是onActiveKeyChanged


void inputMethodChanged()

表示输入法已更改。

注: 相应的处理程序是onInputMethodChanged


void inputMethodReset()

输入法需要重置时发出。

注: 当输入法被激活时,该信号会自动连接至QVirtualKeyboardAbstractInputMethod::reset() 和InputMethod::reset() 。

注: 相应的处理程序是onInputMethodReset


void inputMethodUpdate()

注: 当输入法被激活时,该信号会自动连接至QVirtualKeyboardAbstractInputMethod::update() 和InputMethod::update() 。

注: 相应的处理程序是onInputMethodUpdate


void inputModeChanged()

表示输入模式已更改。

注: 相应的处理程序是onInputModeChanged


void inputModesChanged()

表示可用输入模式已更改。

注: 相应的处理程序是onInputModesChanged


[since QtQuick.VirtualKeyboard 2.0] void patternRecognitionModesChanged()

表示可用的模式识别模式已更改。

预定义的模式识别模式如下:

  • InputEngine.PatternRecognitionMode.None 模式识别不可用。
  • InputEngine.PatternRecognitionMode.PatternRecognitionDisabled obsolete 使用InputEngine.PatternRecognitionMode.None
  • InputEngine.PatternRecognitionMode.Handwriting 用于手写识别的模式识别模式。
  • InputEngine.PatternRecognitionMode.HandwritingRecoginition obsolete 使用InputEngine.PatternRecognitionMode.Handwriting

注: 相应的处理程序是onPatternRecognitionModesChanged

该信号在 QtQuick.VirtualKeyboard 2.0 中引入。


void previousKeyChanged(int key)

表示之前的key 已更改。

注意: 相应的处理程序是onPreviousKeyChanged


void virtualKeyClicked(int key, string text, int modifiers)

表示使用给定的textmodifiers 点击了虚拟key 。该信号在输入法处理完按键事件后发出。

注: 相应的处理程序是onVirtualKeyClicked


方法文档

[since QtQuick.VirtualKeyboard 2.0] Trace traceBegin(int traceId, int patternRecognitionMode, var traceCaptureDeviceInfo, var traceScreenInfo)

启动与输入引擎的跟踪交互。

跟踪的唯一标识是traceId 。如果输入法接受该事件,输入引擎将把 id 分配给跟踪对象。

patternRecognitionMode 指定了用于该模式的识别模式。

如果当前输入法接受该事件,则会返回一个与此交互相关的跟踪对象。如果输入法放弃该事件,则返回一个空值。

traceCaptureDeviceInfo 提供有关源设备的信息,traceScreenInfo 提供有关屏幕上下文的信息。

根据定义,在调用traceEnd() 方法之前,跟踪对象一直有效。

跟踪交互通过调用InputEngine.traceEnd() 方法结束。

该方法在 QtQuick.VirtualKeyboard 2.0 中引入。


bool traceEnd(Trace trace)

结束与输入引擎的跟踪交互。

调用此函数后,可随时丢弃trace 对象。

如果接受了跟踪交互(即触摸事件不应被用于其他用途),则函数返回 true。


void virtualKeyCancel()

在不发出按键事件的情况下恢复活动按键状态。当用户放弃当前按键并需要恢复按键状态时,该方法非常有用。


bool virtualKeyClick(int key, string text, int modifiers)

为给定的keytextmodifiers 发送按键点击事件。如果输入引擎接受了按键事件,则返回true


bool virtualKeyPress(int key, string text, int modifiers, bool repeat)

键盘层调用key 表示textmodifiers 已被按下。

key 被设置为活动键(下键)。当virtualKeyRelease() 方法释放按键时,将触发实际的按键事件。按键按下事件可通过调用virtualKeyCancel() 丢弃。

如果repeattrue ,按键也会启动按键重复计时器。

如果输入引擎接受了按键,则返回true

另请参阅 virtualKeyCancel() 和virtualKeyRelease() 。


bool virtualKeyRelease(int key, string text, int modifiers)

key 释放按键。如果事件不是由重复定时器产生的,则该方法会为输入法发出一个按键事件。textmodifiers 将传递给输入法。

如果输入引擎接受了密钥,则返回true


© 2025 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.