QtBase  v6.3.1
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Properties | Friends | List of all members
QInputMethod Class Reference

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

#include <qinputmethod.h>

Inheritance diagram for QInputMethod:
Inheritance graph
[legend]
Collaboration diagram for QInputMethod:
Collaboration graph
[legend]

Public Types

enum  Action { Click , ContextMenu }
 

Public Slots

void show ()
 
void hide ()
 
void update (Qt::InputMethodQueries queries)
 
void reset ()
 
void commit ()
 
void invokeAction (Action a, int cursorPosition)
 
- Public Slots inherited from QObject
void deleteLater ()
 

Signals

void cursorRectangleChanged ()
 
void anchorRectangleChanged ()
 
void keyboardRectangleChanged ()
 
void inputItemClipRectangleChanged ()
 
void visibleChanged ()
 
void animatingChanged ()
 
void localeChanged ()
 
void inputDirectionChanged (Qt::LayoutDirection newDirection)
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 

Public Member Functions

QTransform inputItemTransform () const
 
void setInputItemTransform (const QTransform &transform)
 
QRectF inputItemRectangle () const
 
void setInputItemRectangle (const QRectF &rect)
 
QRectF cursorRectangle () const
 
QRectF anchorRectangle () const
 
QRectF keyboardRectangle () const
 
QRectF inputItemClipRectangle () const
 
bool isVisible () const
 
void setVisible (bool visible)
 
bool isAnimating () const
 
QLocale locale () const
 
Qt::LayoutDirection inputDirection () const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 

Static Public Member Functions

static QVariant queryFocusObject (Qt::InputMethodQuery query, const QVariant &argument)
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 

Properties

QRectF cursorRectangle
 Input item's cursor rectangle in window coordinates. More...
 
QRectF anchorRectangle
 Input item's anchor rectangle in window coordinates. More...
 
QRectF keyboardRectangle
 Virtual keyboard's geometry in window coordinates. More...
 
QRectF inputItemClipRectangle
 Input item's clipped rectangle in window coordinates. More...
 
bool visible
 Virtual keyboard's visibility on the screen. More...
 
bool animating
 True when the virtual keyboard is being opened or closed. More...
 
QLocale locale
 Current input locale. More...
 
Qt::LayoutDirection inputDirection
 Current input direction. More...
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Friends

class QGuiApplication
 
class QGuiApplicationPrivate
 
class QPlatformInputContext
 

Additional Inherited Members

- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

The QInputMethod class provides access to the active text input method. \inmodule QtGui.

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 \l{QmlGlobalQtObject}{Qt global object} as Qt.inputMethod property.

Definition at line 54 of file qinputmethod.h.

Member Enumeration Documentation

◆ Action

Indicates the kind of action performed by the user.

\value Click A normal click/tap \value ContextMenu A context menu click/tap (e.g. right-button or tap-and-hold)

See also
invokeAction()
Enumerator
Click 
ContextMenu 

Definition at line 84 of file qinputmethod.h.

Member Function Documentation

◆ anchorRectangle()

QRectF QInputMethod::anchorRectangle ( ) const

Definition at line 163 of file qinputmethod.cpp.

◆ anchorRectangleChanged

void QInputMethod::anchorRectangleChanged ( )
signal
Here is the caller graph for this function:

◆ animatingChanged

void QInputMethod::animatingChanged ( )
signal
Here is the caller graph for this function:

◆ commit

void QInputMethod::commit ( )
slot

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 commit() function, for example when the cursor is moved elsewhere.

Definition at line 361 of file qinputmethod.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cursorRectangle()

QRectF QInputMethod::cursorRectangle ( ) const

Definition at line 150 of file qinputmethod.cpp.

◆ cursorRectangleChanged

void QInputMethod::cursorRectangleChanged ( )
signal
Here is the caller graph for this function:

◆ hide

void QInputMethod::hide ( )
slot

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.

Definition at line 221 of file qinputmethod.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inputDirection()

Qt::LayoutDirection QInputMethod::inputDirection ( ) const

Definition at line 295 of file qinputmethod.cpp.

Here is the call graph for this function:

◆ inputDirectionChanged

void QInputMethod::inputDirectionChanged ( Qt::LayoutDirection  newDirection)
signal
Here is the caller graph for this function:

◆ inputItemClipRectangle()

QRectF QInputMethod::inputItemClipRectangle ( ) const

Definition at line 192 of file qinputmethod.cpp.

◆ inputItemClipRectangleChanged

void QInputMethod::inputItemClipRectangleChanged ( )
signal
Here is the caller graph for this function:

◆ inputItemRectangle()

QRectF QInputMethod::inputItemRectangle ( ) const
Since
5.1

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

See also
setInputItemRectangle()

Definition at line 111 of file qinputmethod.cpp.

Here is the caller graph for this function:

◆ inputItemTransform()

QTransform QInputMethod::inputItemTransform ( ) const

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

Definition at line 81 of file qinputmethod.cpp.

Here is the caller graph for this function:

◆ invokeAction

void QInputMethod::invokeAction ( Action  a,
int  cursorPosition 
)
slot

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.

Definition at line 385 of file qinputmethod.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAnimating()

bool QInputMethod::isAnimating ( ) const

Definition at line 269 of file qinputmethod.cpp.

Here is the call graph for this function:

◆ isVisible()

bool QInputMethod::isVisible ( ) const

Definition at line 238 of file qinputmethod.cpp.

Here is the call graph for this function:

◆ keyboardRectangle()

QRectF QInputMethod::keyboardRectangle ( ) const

Definition at line 176 of file qinputmethod.cpp.

Here is the call graph for this function:

◆ keyboardRectangleChanged

void QInputMethod::keyboardRectangleChanged ( )
signal
Here is the caller graph for this function:

◆ locale()

QLocale QInputMethod::locale ( ) const

Definition at line 282 of file qinputmethod.cpp.

Here is the call graph for this function:

◆ localeChanged

void QInputMethod::localeChanged ( )
signal
Here is the caller graph for this function:

◆ queryFocusObject()

QVariant QInputMethod::queryFocusObject ( Qt::InputMethodQuery  query,
const QVariant argument 
)
static

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

Definition at line 422 of file qinputmethod.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset

void QInputMethod::reset ( )
slot

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.

Definition at line 345 of file qinputmethod.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setInputItemRectangle()

void QInputMethod::setInputItemRectangle ( const QRectF rect)
Since
5.1

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.

Definition at line 124 of file qinputmethod.cpp.

Here is the caller graph for this function:

◆ setInputItemTransform()

void QInputMethod::setInputItemTransform ( const QTransform transform)

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.

Definition at line 92 of file qinputmethod.cpp.

Here is the caller graph for this function:

◆ setVisible()

void QInputMethod::setVisible ( bool  visible)

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

See also
show(), hide()

Definition at line 254 of file qinputmethod.cpp.

Here is the call graph for this function:

◆ show

void QInputMethod::show ( )
slot

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.

Definition at line 206 of file qinputmethod.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update

void QInputMethod::update ( Qt::InputMethodQueries  queries)
slot

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 Qt::ImQueryInput value for convenience.

Definition at line 315 of file qinputmethod.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ visibleChanged

void QInputMethod::visibleChanged ( )
signal
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ QGuiApplication

friend class QGuiApplication
friend

Definition at line 121 of file qinputmethod.h.

◆ QGuiApplicationPrivate

friend class QGuiApplicationPrivate
friend

Definition at line 122 of file qinputmethod.h.

◆ QPlatformInputContext

friend class QPlatformInputContext
friend

Definition at line 123 of file qinputmethod.h.

Property Documentation

◆ anchorRectangle

QInputMethod::anchorRectangle
read

Input item's anchor rectangle in window coordinates.

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

Definition at line 128 of file qinputmethod.h.

◆ animating

QInputMethod::animating
read

True when the virtual keyboard is being opened or closed.

Animating 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.

Definition at line 128 of file qinputmethod.h.

◆ cursorRectangle

QInputMethod::cursorRectangle
read

Input item's cursor rectangle in window coordinates.

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

Definition at line 128 of file qinputmethod.h.

◆ inputDirection

QInputMethod::inputDirection
read

Current input direction.

Definition at line 128 of file qinputmethod.h.

◆ inputItemClipRectangle

QInputMethod::inputItemClipRectangle
read

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).

Definition at line 128 of file qinputmethod.h.

◆ keyboardRectangle

QInputMethod::keyboardRectangle
read

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.

Definition at line 128 of file qinputmethod.h.

◆ locale

QInputMethod::locale
read

Current input locale.

Definition at line 128 of file qinputmethod.h.

◆ visible

QInputMethod::visible
read

Virtual keyboard's visibility on the screen.

Input method visibility remains false for devices with no virtual keyboards.

See also
show(), hide()

Definition at line 128 of file qinputmethod.h.


The documentation for this class was generated from the following files: