InputEngine Class

(QtVirtualKeyboard::InputEngine)

The InputEngine class provides an input engine that supports C++ and QML integration. More...

Header: #include <InputEngine>
Instantiated By: InputEngine
Inherits: QObject

Public Types

enum InputMode { Latin, Numeric, Dialable, Pinyin, ..., FullwidthLatin }
enum PatternRecognitionMode { PatternRecognitionDisabled, HandwritingRecoginition }
enum ReselectFlag { WordBeforeCursor, WordAfterCursor, WordAtCursor }
flags ReselectFlags
enum TextCase { Lower, Upper }

Properties

  • 1 property inherited from QObject

Public Functions

Qt::Key activeKey() const
InputContext *inputContext() const
AbstractInputMethod *inputMethod() const
InputMode inputMode() const
QList<int> inputModes() const
QList<int> patternRecognitionModes() const
Qt::Key previousKey() const
bool reselect(int cursorPosition, const ReselectFlags &reselectFlags)
void setInputMethod(AbstractInputMethod *inputMethod)
void setInputMode(InputMode inputMode)
QtVirtualKeyboard::Trace *traceBegin(int traceId, QtVirtualKeyboard::InputEngine::PatternRecognitionMode patternRecognitionMode, const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo)
bool traceEnd(QtVirtualKeyboard::Trace *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)
SelectionListModel *wordCandidateListModel() const
bool wordCandidateListVisibleHint() const
  • 31 public functions inherited from QObject

Signals

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

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The InputEngine class provides an input engine that supports C++ and QML integration.

The input engine is responsible for routing input events to input methods. The actual input logic is implemented by the input methods.

The input engine also includes the default input method, which takes care of default processing if the active input method does not handle the event.

Member Type Documentation

enum InputEngine::InputMode

This enum specifies the input mode for the input method.

ConstantValueDescription
QtVirtualKeyboard::InputEngine::Latin0The default input mode for latin text.
QtVirtualKeyboard::InputEngine::Numeric1Only numeric input is allowed.
QtVirtualKeyboard::InputEngine::Dialable2Only dialable input is allowed.
QtVirtualKeyboard::InputEngine::Pinyin3Pinyin input mode for Chinese.
QtVirtualKeyboard::InputEngine::Cangjie4Cangjie input mode for Chinese.
QtVirtualKeyboard::InputEngine::Zhuyin5Zhuyin input mode for Chinese.
QtVirtualKeyboard::InputEngine::Hangul6Hangul input mode for Korean.
QtVirtualKeyboard::InputEngine::Hiragana7Hiragana input mode for Japanese.
QtVirtualKeyboard::InputEngine::Katakana8Katakana input mode for Japanese.
QtVirtualKeyboard::InputEngine::FullwidthLatin9Fullwidth latin input mode for East Asian languages.

enum InputEngine::PatternRecognitionMode

This enum specifies the input mode for the input method.

ConstantValueDescription
QtVirtualKeyboard::InputEngine::PatternRecognitionDisabled0Pattern recognition is not available.
QtVirtualKeyboard::InputEngine::HandwritingRecoginition1Pattern recognition mode for handwriting recognition.

enum InputEngine::ReselectFlag
flags InputEngine::ReselectFlags

This enum specifies the rules for word reselection.

ConstantValueDescription
QtVirtualKeyboard::InputEngine::WordBeforeCursor0x1Activate the word before the cursor. When this flag is used exclusively, the word must end exactly at the cursor.
QtVirtualKeyboard::InputEngine::WordAfterCursor0x2Activate the word after the cursor. When this flag is used exclusively, the word must start exactly at the cursor.
QtVirtualKeyboard::InputEngine::WordAtCursorWordBeforeCursor | WordAfterCursorActivate 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.

The ReselectFlags type is a typedef for QFlags<ReselectFlag>. It stores an OR combination of ReselectFlag values.

enum InputEngine::TextCase

This enum specifies the text case for the input method.

ConstantValueDescription
QtVirtualKeyboard::InputEngine::Lower0Lower case text.
QtVirtualKeyboard::InputEngine::Upper1Upper case text.

Property Documentation

activeKey : const Qt::Key

This property holds the active key.

Currently pressed key.

Access functions:

Qt::Key activeKey() const

Notifier signal:

void activeKeyChanged(Qt::Key key)

inputMethod : QtVirtualKeyboard::AbstractInputMethod *

This property holds the active input method.

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

Access functions:

AbstractInputMethod *inputMethod() const
void setInputMethod(AbstractInputMethod *inputMethod)

Notifier signal:

inputMode : InputMode

This property holds the current input mode.

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.

Access functions:

InputMode inputMode() const
void setInputMode(InputMode inputMode)

Notifier signal:

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.

Access functions:

QList<int> inputModes() const

Notifier signal:

patternRecognitionModes : const QList<int>

This property holds the list of available pattern recognition modes.

The list of available pattern recognition modes.

This property was introduced in QtQuick.VirtualKeyboard 2.0.

Access functions:

QList<int> patternRecognitionModes() const

Notifier signal:

previousKey : const Qt::Key

This property holds the previous active key.

Previously pressed key.

Access functions:

Qt::Key previousKey() const

Notifier signal:

void previousKeyChanged(Qt::Key key)

wordCandidateListModel : QtVirtualKeyboard::SelectionListModel * const

This property holds list model for the word candidate list.

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

Access functions:

SelectionListModel *wordCandidateListModel() const

Notifier signal:

void wordCandidateListModelChanged()

wordCandidateListVisibleHint : const bool

This property holds visible hint for the word candidate list.

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

Access functions:

bool wordCandidateListVisibleHint() const

Notifier signal:

void wordCandidateListVisibleHintChanged()

Member Function Documentation

Qt::Key InputEngine::activeKey() const

Returns the currently active key, or Qt::Key_unknown if no key is active.

Note: Getter function for property activeKey.

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

Indicates that the active key has changed.

Note: Notifier signal for property activeKey.

InputContext *InputEngine::inputContext() const

Returns the InputContext instance associated with the input engine.

AbstractInputMethod *InputEngine::inputMethod() const

Returns the active input method.

Note: Getter function for property inputMethod.

See also setInputMethod().

[signal] void InputEngine::inputMethodChanged()

Indicates that the input method has changed.

Note: Notifier signal for property inputMethod.

[signal] void InputEngine::inputMethodReset()

Emitted when the input method needs to be reset.

Note: This signal is automatically connected to AbstractInputMethod::reset() and InputMethod::reset() when the input method is activated.

[signal] void InputEngine::inputMethodUpdate()

Note: This signal is automatically connected to AbstractInputMethod::update() and InputMethod::update() when the input method is activated.

[signal] void InputEngine::inputModeChanged()

Indicates that the input mode has changed.

Note: Notifier signal for property inputMode.

QList<int> InputEngine::inputModes() const

Returns the list of available input modes.

Note: Getter function for property inputModes.

[signal] void InputEngine::inputModesChanged()

Indicates that the available input modes have changed.

Note: Notifier signal for property inputModes.

QList<int> InputEngine::patternRecognitionModes() const

Returns list of supported pattern recognition modes.

Note: Getter function for property patternRecognitionModes.

[signal] void InputEngine::patternRecognitionModesChanged()

Indicates that the available pattern recognition modes have changed.

This function was introduced in QtQuick.VirtualKeyboard 2.0.

Note: Notifier signal for property patternRecognitionModes.

Qt::Key InputEngine::previousKey() const

Returns the previously active key, or Qt::Key_unknown if no key has been active.

Note: Getter function for property previousKey.

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

Indicates that the previous key has changed.

Note: Notifier signal for property previousKey.

bool InputEngine::reselect(int cursorPosition, const ReselectFlags &reselectFlags)

This function attempts to reselect a word located at the cursorPosition. The reselectFlags define the rules for how the word should be selected in relation to the cursor position.

The function returns true if the word was successfully reselected.

This function was introduced in QtQuick.VirtualKeyboard 2.0.

void InputEngine::setInputMethod(AbstractInputMethod *inputMethod)

Sets inputMethod as the active input method.

Note: Setter function for property inputMethod.

See also inputMethod().

QtVirtualKeyboard::Trace *InputEngine::traceBegin(int traceId, QtVirtualKeyboard::InputEngine::PatternRecognitionMode patternRecognitionMode, const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo)

Starts a trace interaction with the input engine.

The trace is uniquely identified by the traceId. The input engine will assign the id to the Trace 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 Trace object associated with this interaction. If the input method discards the event, it returns a NULL value.

The traceCaptureDeviceInfo provides information about the source device and the traceScreenInfo provides information about the screen context.

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

The trace interaction is ended by calling the traceEnd() method.

This function was introduced in QtQuick.VirtualKeyboard 2.0.

bool InputEngine::traceEnd(QtVirtualKeyboard::Trace *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).

void InputEngine::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.

bool InputEngine::virtualKeyClick(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers)

Emits a key click event for the given key, text and modifiers. Returns true if the key event was accepted by the input engine.

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

Indicates that the virtual key was clicked with the given text and modifiers. The 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.

bool InputEngine::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.

Returns true if the key was accepted by this input engine.

See also virtualKeyCancel() and virtualKeyRelease().

bool InputEngine::virtualKeyRelease(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers)

Releases the key at 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.

Returns true if the key was accepted by the input engine.