QVirtualKeyboardInputEngine 类

The InputEngine 类提供支持 C++ 和 QML 集成的输入引擎。 更多...

头: #include <QVirtualKeyboardInputEngine>
CMake: find_package(Qt6 REQUIRED COMPONENTS VirtualKeyboard)
target_link_libraries(mytarget PRIVATE Qt6::VirtualKeyboard)
qmake: QT += virtualkeyboard
实例化: InputEngine
继承: QObject

公共类型

enum class InputMode { Latin, Numeric, Dialable, Pinyin, Cangjie, …, Romaji }
enum class PatternRecognitionMode { None, PatternRecognitionDisabled, Handwriting, HandwritingRecoginition }
enum class ReselectFlag { WordBeforeCursor, WordAfterCursor, WordAtCursor }
flags ReselectFlags
enum class TextCase { Lower, Upper }

特性

公共函数

Qt::Key activeKey () const
QVirtualKeyboardInputContext * inputContext () const
QVirtualKeyboardAbstractInputMethod * inputMethod () const
QVirtualKeyboardInputEngine::InputMode inputMode () const
QList<int> inputModes () const
QList<int> patternRecognitionModes () const
Qt::Key previousKey () const
(since QtQuick.VirtualKeyboard 2.0) bool reselect (int cursorPosition , const QVirtualKeyboardInputEngine::ReselectFlags & reselectFlags )
void setInputMethod (QVirtualKeyboardAbstractInputMethod * inputMethod )
void setInputMode (QVirtualKeyboardInputEngine::InputMode inputMode )
(since QtQuick.VirtualKeyboard 2.0) QVirtualKeyboardTrace * traceBegin (int traceId , QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode , const QVariantMap & traceCaptureDeviceInfo , const QVariantMap & traceScreenInfo )
bool traceEnd (QVirtualKeyboardTrace * trace )
void virtualKeyCancel ()
bool virtualKeyClick (Qt::Key key , const QString & text , Qt::KeyboardModifiers modifiers )
bool virtualKeyPress (Qt::Key key , const QString & text , Qt::KeyboardModifiers modifiers , bool repeat )
bool virtualKeyRelease (Qt::Key key , const QString & text , Qt::KeyboardModifiers modifiers )
QVirtualKeyboardSelectionListModel * wordCandidateListModel () const
bool wordCandidateListVisibleHint () const

信号

void activeKeyChanged (Qt::Key key )
void inputMethodChanged ()
void inputMethodReset ()
void inputMethodUpdate ()
void inputModeChanged ()
void inputModesChanged ()
(since QtQuick.VirtualKeyboard 2.0) void patternRecognitionModesChanged ()
void previousKeyChanged (Qt::Key key )
void virtualKeyClicked (Qt::Key key , const QString & text , Qt::KeyboardModifiers modifiers , bool isAutoRepeat )
void wordCandidateListModelChanged ()
void wordCandidateListVisibleHintChanged ()

详细描述

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

输入引擎还包括默认输入法,负责默认处理若活动输入法不处理事件。

成员类型文档编制

enum class QVirtualKeyboardInputEngine:: InputMode

此枚举指定输入法的输入方式。

常量 描述
QVirtualKeyboardInputEngine::InputMode::Latin 0 用于拉丁文本的默认输入方式。
QVirtualKeyboardInputEngine::InputMode::Numeric 1 Only numeric input is allowed.
QVirtualKeyboardInputEngine::InputMode::Dialable 2 Only dialable input is allowed.
QVirtualKeyboardInputEngine::InputMode::Pinyin 3 Pinyin input mode for Chinese.
QVirtualKeyboardInputEngine::InputMode::Cangjie 4 Cangjie input mode for Chinese.
QVirtualKeyboardInputEngine::InputMode::Zhuyin 5 Zhuyin input mode for Chinese.
QVirtualKeyboardInputEngine::InputMode::Hangul 6 Hangul input mode for Korean.
QVirtualKeyboardInputEngine::InputMode::Hiragana 7 Hiragana input mode for Japanese.
QVirtualKeyboardInputEngine::InputMode::Katakana 8 Katakana input mode for Japanese.
QVirtualKeyboardInputEngine::InputMode::FullwidthLatin 9 Fullwidth latin input mode for East Asian languages.
QVirtualKeyboardInputEngine::InputMode::Greek 10 希腊语输入方式。
QVirtualKeyboardInputEngine::InputMode::Cyrillic 11 西里尔输入方式。
QVirtualKeyboardInputEngine::InputMode::Arabic 12 阿拉伯语输入方式。
QVirtualKeyboardInputEngine::InputMode::Hebrew 13 希伯来语输入方式。
QVirtualKeyboardInputEngine::InputMode::ChineseHandwriting 14 Chinese handwriting input mode.
QVirtualKeyboardInputEngine::InputMode::JapaneseHandwriting 15 Japanese handwriting input mode.
QVirtualKeyboardInputEngine::InputMode::KoreanHandwriting 16 Korean handwriting input mode.
QVirtualKeyboardInputEngine::InputMode::Thai 17 泰语输入方式。
QVirtualKeyboardInputEngine::InputMode::Stroke 18 Stroke input mode for Chinese.
QVirtualKeyboardInputEngine::InputMode::Romaji 19 Romaji input mode for Japanese.

enum class QVirtualKeyboardInputEngine:: PatternRecognitionMode

此枚举指定输入法的输入方式。

常量 描述
QVirtualKeyboardInputEngine::PatternRecognitionMode::None 0 Pattern recognition is not available.
QVirtualKeyboardInputEngine::PatternRecognitionMode::PatternRecognitionDisabled None obsolete Use PatternRecognitionMode::None
QVirtualKeyboardInputEngine::PatternRecognitionMode::Handwriting 1 Pattern recognition mode for handwriting recognition.
QVirtualKeyboardInputEngine::PatternRecognitionMode::HandwritingRecoginition Handwriting obsolete Use PatternRecognitionMode::Handwriting

enum class QVirtualKeyboardInputEngine:: ReselectFlag
flags QVirtualKeyboardInputEngine:: ReselectFlags

此枚举指定用于单词重选的规则。

常量 描述
QVirtualKeyboardInputEngine::ReselectFlag::WordBeforeCursor 0x1 Activate the word before the cursor. When this flag is used exclusively, the word must end exactly at the cursor.
QVirtualKeyboardInputEngine::ReselectFlag::WordAfterCursor 0x2 Activate the word after the cursor. When this flag is used exclusively, the word must start exactly at the cursor.
QVirtualKeyboardInputEngine::ReselectFlag::WordAtCursor WordBeforeCursor | WordAfterCursor Activate the word at the cursor. This flag is a combination of the above flags with the exception that the word cannot start or stop at the cursor.

ReselectFlags 类型是 typedef 对于 QFlags <ReselectFlag>。它存储 ReselectFlag 值的 OR 组合。

enum class QVirtualKeyboardInputEngine:: TextCase

此枚举指定用于输入法的文本大小写。

常量 描述
QVirtualKeyboardInputEngine::TextCase::Lower 0 小写文本。
QVirtualKeyboardInputEngine::TextCase::Upper 1 大写文本。

特性文档编制

[read-only] activeKey : const Qt::Key

此特性保持活动键。

目前按下的键。

访问函数:

Qt::Key activeKey () const

通知程序信号:

void activeKeyChanged (Qt::Key key )

inputMethod : QVirtualKeyboardAbstractInputMethod *

此特性保持活动输入法。

Use this property to set active the input method, or to monitor when the active input method changes.

访问函数:

QVirtualKeyboardAbstractInputMethod * inputMethod () const
void setInputMethod (QVirtualKeyboardAbstractInputMethod * inputMethod )

通知程序信号:

void inputMethodChanged ()

inputMode : InputMode

此特性保持当前输入方式。

Use this property to get or set the current input mode. The InputEngine::inputModes provides list of valid input modes for current input method and locale.

访问函数:

QVirtualKeyboardInputEngine::InputMode inputMode () const
void setInputMode (QVirtualKeyboardInputEngine::InputMode inputMode )

通知程序信号:

void inputModeChanged ()

[read-only] inputModes : const QList < int >

This property holds the available input modes for active input method.

The list of available input modes is dependent on the input method and locale. This property is updated when either of the dependencies changes.

访问函数:

QList<int> inputModes () const

通知程序信号:

void inputModesChanged ()

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

This property holds the list of available pattern recognition modes.

The list of available pattern recognition modes.

该特性在 QtQuick.VirtualKeyboard 2.0 引入。

访问函数:

QList<int> patternRecognitionModes () const

通知程序信号:

void patternRecognitionModesChanged ()

[read-only] previousKey : const Qt::Key

此特性保持先前活动的键。

先前按下的键。

访问函数:

Qt::Key previousKey () const

通知程序信号:

void previousKeyChanged (Qt::Key key )

[read-only] wordCandidateListModel : QVirtualKeyboardSelectionListModel * const

用于单词候选列表的列表模型。

Use this property to access the list model for the word candidate list.

访问函数:

QVirtualKeyboardSelectionListModel * wordCandidateListModel () const

通知程序信号:

void wordCandidateListModelChanged ()

[read-only] wordCandidateListVisibleHint : const bool

用于单词候选列表的可见提示。

Use this property to check if the word candidate list should be visible in the UI.

访问函数:

bool wordCandidateListVisibleHint () const

通知程序信号:

void wordCandidateListVisibleHintChanged ()

成员函数文档编制

Qt::Key QVirtualKeyboardInputEngine:: activeKey () const

返回目前活动的键,或 Qt::Key_unknown 若没有活动键。

注意: getter 函数对于特性 activeKey。

[signal] void QVirtualKeyboardInputEngine:: activeKeyChanged ( Qt::Key key )

指示活动 key 已改变。

注意: 通知程序信号对于特性 activeKey .

QVirtualKeyboardInputContext *QVirtualKeyboardInputEngine:: inputContext () const

返回 InputContext 实例有关联输入引擎。

QVirtualKeyboardAbstractInputMethod *QVirtualKeyboardInputEngine:: inputMethod () const

返回活动输入法。

注意: getter 函数对于特性 inputMethod。

另请参阅 setInputMethod ().

[signal] void QVirtualKeyboardInputEngine:: inputMethodChanged ()

指示输入法已改变。

注意: 通知程序信号对于特性 inputMethod .

[signal] void QVirtualKeyboardInputEngine:: inputMethodReset ()

发射当需要重置输入法时。

注意: 此信号会被自动连接到 QVirtualKeyboardAbstractInputMethod::reset () 和 InputMethod::reset () when the input method is activated.

[signal] void QVirtualKeyboardInputEngine:: inputMethodUpdate ()

注意: 此信号会被自动连接到 QVirtualKeyboardAbstractInputMethod::update () 和 InputMethod::update () when the input method is activated.

[signal] void QVirtualKeyboardInputEngine:: inputModeChanged ()

指示输入方式已改变。

注意: 通知程序信号对于特性 inputMode .

QList < int > QVirtualKeyboardInputEngine:: inputModes () const

返回可用输入方式的列表。

注意: getter 函数对于特性 inputModes。

[signal] void QVirtualKeyboardInputEngine:: inputModesChanged ()

指示可用输入方式已改变。

注意: 通知程序信号对于特性 inputModes .

QList < int > QVirtualKeyboardInputEngine:: patternRecognitionModes () const

返回支持模式识别方式的列表。

注意: getter 函数对于特性 patternRecognitionModes。

[signal, since QtQuick.VirtualKeyboard 2.0] void QVirtualKeyboardInputEngine:: patternRecognitionModesChanged ()

Indicates that the available pattern recognition modes have changed.

注意: 通知程序信号对于特性 patternRecognitionModes .

该函数在 QtQuick.VirtualKeyboard 2.0 引入。

Qt::Key QVirtualKeyboardInputEngine:: previousKey () const

返回先前活动的键,或 Qt::Key_unknown 若没有活动键。

注意: getter 函数对于特性 previousKey。

[signal] void QVirtualKeyboardInputEngine:: previousKeyChanged ( Qt::Key key )

指示先前 key 已改变。

注意: 通知程序信号对于特性 previousKey .

[invokable, since QtQuick.VirtualKeyboard 2.0] bool QVirtualKeyboardInputEngine:: reselect ( int cursorPosition , const QVirtualKeyboardInputEngine::ReselectFlags & reselectFlags )

此函数试图重选的单词位于 cursorPosition reselectFlags 定义应如何选择光标位置相关单词的规则。

函数返回 true 若单词被成功重选。

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

该函数在 QtQuick.VirtualKeyboard 2.0 引入。

void QVirtualKeyboardInputEngine:: setInputMethod ( QVirtualKeyboardAbstractInputMethod * inputMethod )

设置 inputMethod 作为活动输入法。

注意: setter 函数对于特性 inputMethod .

另请参阅 inputMethod ().

[invokable, since QtQuick.VirtualKeyboard 2.0] QVirtualKeyboardTrace *QVirtualKeyboardInputEngine:: traceBegin ( int traceId , QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode , const QVariantMap & traceCaptureDeviceInfo , const QVariantMap & traceScreenInfo )

采用输入引擎开始跟踪交互。

The trace is uniquely identified by the traceId . The input engine will assign the id to the QVirtualKeyboardTrace object if the input method accepts the event.

The patternRecognitionMode specifies the recognition mode used for the pattern.

If the current input method accepts the event it returns a QVirtualKeyboardTrace object associated with this interaction. If the input method discards the event, it returns a NULL value.

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

By definition, the QVirtualKeyboardTrace object remains valid until the traceEnd () method is called.

The trace interaction is ended by calling the traceEnd () 方法。

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

该函数在 QtQuick.VirtualKeyboard 2.0 引入。

[invokable] bool QVirtualKeyboardInputEngine:: traceEnd ( QVirtualKeyboardTrace * trace )

Ends the trace interaction with the input engine.

The trace object may be discarded at any point after calling this function.

The function returns true if the trace interaction was accepted (i.e. the touch events should not be used for anything else).

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] void QVirtualKeyboardInputEngine:: virtualKeyCancel ()

Reverts the active key state without emitting the key event. This method is useful when the user discards the current key and the key state needs to be restored.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[invokable] bool QVirtualKeyboardInputEngine:: virtualKeyClick ( Qt::Key key , const QString & text , Qt::KeyboardModifiers modifiers )

发射键点击事件为给定 key , text and modifiers 。返回 true 若输入引擎接受键事件。

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

[signal] void QVirtualKeyboardInputEngine:: virtualKeyClicked ( Qt::Key key , const QString & text , Qt::KeyboardModifiers modifiers , bool isAutoRepeat )

指示虚拟 key was clicked with the given text and modifiers isAutoRepeat indicates if the event is automatically repeated while the key is being pressed. This signal is emitted after the input method has processed the key event.

[invokable] bool QVirtualKeyboardInputEngine:: virtualKeyPress ( Qt::Key key , const QString & text , Qt::KeyboardModifiers modifiers , bool repeat )

Called by the keyboard layer to indicate that key was pressed, with the given text and modifiers .

The key is set as an active key (down key). The actual key event is triggered when the key is released by the virtualKeyRelease () method. The key press event can be discarded by calling virtualKeyCancel ().

The key press also initiates the key repeat timer if repeat is true .

返回 true 若此输入引擎接受键。

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

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

[invokable] bool QVirtualKeyboardInputEngine:: virtualKeyRelease ( Qt::Key key , const QString & text , Qt::KeyboardModifiers modifiers )

释放键如 key . The method emits a key event for the input method if the event has not been generated by a repeating timer. The text and modifiers are passed to the input method.

返回 true 若输入引擎接受键。

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .