- Qt 6.11
- Qt Quick
- QML Types
- InputMethod
- Qt 6.11.1 Reference Documentation

# InputMethod QML Type (Singleton)

Provides access to QInputMethod for QML applications. More...

Import Statement: | `import QtQuick`
Since: | Qt 6.4

Note: This type is a QML singleton. There is only one instance of this type in the QML engine.

- List of all members, including inherited members

## Properties

- anchorRectangle : rect
- animating : bool
- cursorRectangle : rect
- inputDirection : enumeration
- inputItemClipRectangle : rect
- keyboardRectangle : rect
- locale : Locale
- visible : bool

## Methods

- void commit()
- void hide()
- void invokeAction(var a, int cursorPosition)
- void reset()
- void show()
- void update(enumeration queries)

## Detailed Description

The InputMethod singleton allows access to application's QInputMethod object and all its properties and slots. See the QInputMethod documentation for further details.

## Property Documentation

### anchorRectangle : rect

Input item's anchor rectangle in window coordinates.

The anchor rectangle is often used by various text editing controls like text prediction popups for following the text selection.

### animating : bool

True when the virtual keyboard is being opened or closed.

The value of this property is false when keyboard is fully open or closed. When `animating` is `true` and `visibility` is `true` keyboard is being opened. When `animating` is `true` and `visibility` is false keyboard is being closed.

### cursorRectangle : rect

Input item's cursor rectangle in window coordinates.

The cursor rectangle is often used by various text editing controls like text prediction popups for following the text being typed.

### inputDirection : enumeration

Current input direction.

Possible values:

Constant | Description
--- | ---
`Qt.LeftToRight` | (default) Items are laid out from left to right.
`Qt.RightToLeft` | Items are laid out from right to left.

### inputItemClipRectangle : rect

Input item's clipped rectangle in window coordinates.

The clipped input rectangle is often used by various input methods to determine how much screen real estate is available for the input method (e.g. Virtual Keyboard).

### keyboardRectangle : rect

Virtual keyboard's geometry in window coordinates.

This might be an empty rectangle if it is not possible to know the geometry of the keyboard. This is the case for a floating keyboard on android.

### locale : Locale

Current input locale.

### visible : bool

Virtual keyboard's visibility on the screen

The value of this property remains false for devices with no virtual keyboards.

See also show() and hide().

## Method Documentation

### void commit()

Commits the word that the user is currently composing to the editor. The function is mostly needed by the input methods with text prediction features and by the methods where the script used for typing characters is different from the script that actually gets appended to the editor. Any kind of action that interrupts the text composing needs to flush the composing state by calling the commit() function, for example when the cursor is moved elsewhere.

### void hide()

Requests the virtual keyboard to close.

Normally applications should not need to call this function, as the keyboard should close automatically when the text editor loses focus, for example when the parent view is closed.

### void invokeAction(var a, int cursorPosition)

Called by the input item when the word currently being composed is tapped by the user, as indicated by the action a and the given cursorPosition. Input methods often use this information to offer more word suggestions to the user.

See also QInputMethod::Action.

### void reset()

Resets the input method state. For example, a text editor normally calls this method before inserting a text to make widget ready to accept a text.

Input method resets automatically when the focused editor changes.

### void show()

Requests the virtual keyboard to open. If the platform doesn't provide a virtual keyboard the visibility remains false.

Normally applications should not need to call this function, as the keyboard should open automatically when the text editor gains focus.

### void update(enumeration queries)

Called by the input item to inform the platform input methods when there have been state changes in the editor's input method query attributes. When calling the function queries parameter has to be used to tell what has changed. An input method can use this to make queries for attributes it is interested in with QInputMethodQueryEvent.

In particular calling update() whenever the cursor position changes is important as that often causes other query attributes, like surrounding text and text selection, to change as well. The attributes that often change together with cursor position have been grouped in Qt::ImQueryInput value for convenience.

See also Qt::InputMethodQueries.