QInputMethod

The QInputMethod class provides access to the active text input method. More

Inheritance diagram of PySide6.QtGui.QInputMethod

Synopsis

Functions

Static functions

Detailed Description

QInputMethod is used by the text editors for integrating to the platform text input methods and more commonly by application views for querying various text input method-related information like virtual keyboard visibility and keyboard dimensions.

Qt Quick also provides access to QInputMethod in QML through Qt global object as Qt.inputMethod property.

class PySide6.QtGui.QInputMethod
PySide6.QtGui.QInputMethod.Action

Indicates the kind of action performed by the user.

Constant

Description

QInputMethod.Click

A normal click/tap

QInputMethod.ContextMenu

A context menu click/tap (e.g. right-button or tap-and-hold)

See also

invokeAction()

PySide6.QtGui.QInputMethod.anchorRectangle()
Return type

PySide6.QtCore.QRectF

PySide6.QtGui.QInputMethod.anchorRectangleChanged()
PySide6.QtGui.QInputMethod.animatingChanged()
PySide6.QtGui.QInputMethod.commit()

Commits the word 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 function, for example when the cursor is moved elsewhere.

PySide6.QtGui.QInputMethod.cursorRectangle()
Return type

PySide6.QtCore.QRectF

PySide6.QtGui.QInputMethod.cursorRectangleChanged()
PySide6.QtGui.QInputMethod.hide()

Requests virtual keyboard to close.

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

PySide6.QtGui.QInputMethod.inputDirection()
Return type

LayoutDirection

PySide6.QtGui.QInputMethod.inputDirectionChanged(newDirection)
Parameters

newDirectionLayoutDirection

PySide6.QtGui.QInputMethod.inputItemClipRectangle()
Return type

PySide6.QtCore.QRectF

PySide6.QtGui.QInputMethod.inputItemClipRectangleChanged()
PySide6.QtGui.QInputMethod.inputItemRectangle()
Return type

PySide6.QtCore.QRectF

Returns the input item’s geometry in input item coordinates.

PySide6.QtGui.QInputMethod.inputItemTransform()
Return type

PySide6.QtGui.QTransform

Returns the transformation from input item coordinates to the window coordinates.

PySide6.QtGui.QInputMethod.invokeAction(a, cursorPosition)
Parameters
  • aAction

  • cursorPosition – int

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.

PySide6.QtGui.QInputMethod.isAnimating()
Return type

bool

PySide6.QtGui.QInputMethod.isVisible()
Return type

bool

PySide6.QtGui.QInputMethod.keyboardRectangle()
Return type

PySide6.QtCore.QRectF

PySide6.QtGui.QInputMethod.keyboardRectangleChanged()
PySide6.QtGui.QInputMethod.locale()
Return type

PySide6.QtCore.QLocale

PySide6.QtGui.QInputMethod.localeChanged()
static PySide6.QtGui.QInputMethod.queryFocusObject(query, argument)
Parameters
Return type

object

Send query to the current focus object with parameters argument and return the result.

PySide6.QtGui.QInputMethod.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.

PySide6.QtGui.QInputMethod.setInputItemRectangle(rect)
Parameters

rectPySide6.QtCore.QRectF

Sets the input item’s geometry to be rect, in input item coordinates. This needs to be updated by the focused window like QQuickCanvas whenever item is moved inside the scene, or focus is changed.

PySide6.QtGui.QInputMethod.setInputItemTransform(transform)
Parameters

transformPySide6.QtGui.QTransform

Sets the transformation from input item coordinates to window coordinates to be transform. Item transform needs to be updated by the focused window like QQuickCanvas whenever item is moved inside the scene.

PySide6.QtGui.QInputMethod.setVisible(visible)
Parameters

visible – bool

Controls the keyboard visibility. Equivalent to calling show() (if visible is true) or hide() (if visible is false).

PySide6.QtGui.QInputMethod.show()

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

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

PySide6.QtGui.QInputMethod.update(queries)
Parameters

queriesInputMethodQueries

Called by the input item to inform the platform input methods when there has been state changes in editor’s input method query attributes. When calling the function queries parameter has to be used to tell what has changes, which input method can use to make queries for attributes it’s interested 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 ImQueryInput value for convenience.

PySide6.QtGui.QInputMethod.visibleChanged()