InputContext QML Type (Singleton)
提供对输入上下文的访问。更多...
| Import Statement: | import QtQuick.VirtualKeyboard |
| In C++: | QVirtualKeyboardInputContext |
注意:此类型是 QML 单例。QML 引擎中仅存在一个此类型的实例。
属性
- anchorPosition : int
(since QtQuick.VirtualKeyboard 2.2) - anchorRectIntersectsClipRect : bool
- anchorRectangle : rect
(since QtQuick.VirtualKeyboard 2.1) - animating : bool
- capsLockActive : bool
(since QtQuick.VirtualKeyboard 2.4) - cursorPosition : int
- cursorRectIntersectsClipRect : bool
- cursorRectangle : rect
- inputEngine : InputEngine
- inputMethodHints : int
- keyboardObserver : KeyboardObserver
(since 6.1) - locale : string
- preeditText : string
- selectedText : string
- selectionControlVisible : bool
- shiftActive : bool
(since QtQuick.VirtualKeyboard 2.4) - surroundingText : string
- uppercase : bool
(since QtQuick.VirtualKeyboard 2.2)
方法
- void clear()
- void commit()
- void commit(string text, int replaceFrom, int replaceLength)
- void sendKeyClick(int key, string text, int modifiers)
详细说明
InputContext 可以作为单例实例进行访问。
属性文档
anchorPosition : int [read-only, since QtQuick.VirtualKeyboard 2.2]
当锚点位置发生变化时,该属性也会随之改变。
该属性是在 QtQuick.VirtualKeyboard 2.2 版本中引入的。
anchorRectIntersectsClipRect : bool [read-only]
如果选择锚点的边界矩形与暴露的输入项矩形发生相交,则返回true 。
另请参阅 Qt::ImAnchorRectangle 和Qt::ImInputItemClipRectangle 。
anchorRectangle : rect [read-only, since QtQuick.VirtualKeyboard 2.1]
当锚点矩形发生变化时,该属性也会随之改变。
该属性自 QtQuick.VirtualKeyboard 2.1 版本起引入。
animating : bool
使用此属性来设置动画状态,例如在 UI 状态转换期间。
capsLockActive : bool [read-only, since QtQuick.VirtualKeyboard 2.4]
当大写锁定状态发生变化时,该属性也会随之改变。
该属性是在 QtQuick.VirtualKeyboard 2.4 版本中引入的。
cursorPosition : int [read-only]
当光标位置发生变化时,该属性也会随之改变。
cursorRectIntersectsClipRect : bool [read-only]
如果输入光标的边界矩形与已暴露的输入项矩形发生相交,则返回true 。
另请参阅 Qt::ImCursorRectangle 和Qt::ImInputItemClipRectangle 。
cursorRectangle : rect [read-only]
当光标矩形发生变化时,该属性也会随之改变。
inputEngine : InputEngine [read-only]
该属性用于存储输入引擎。
inputMethodHints : int [read-only]
当输入法提示发生变化时,该属性也会随之改变。
keyboardObserver : KeyboardObserver [read-only, since 6.1]
保存键盘观察者对象,可用于接收键盘变化事件的通知。
该属性在 Qt 6.1 中引入。
locale : string [read-only]
当输入区域设置发生变化时,此属性也会随之改变。
preeditText : string
此属性用于设置预编辑文本。
selectedText : string [read-only]
当所选文本发生变化时,该属性也会随之改变。
selectionControlVisible : bool [read-only]
如果选择控件当前可见,则返回true 。
shiftActive : bool [read-only, since QtQuick.VirtualKeyboard 2.4]
当 Shift 状态发生变化时,该属性也会随之改变。
该属性是在 QtQuick.VirtualKeyboard 2.4 版本中引入的。
surroundingText : string [read-only]
当光标周围的文本发生变化时,该属性也会随之改变。
uppercase : bool [read-only, since QtQuick.VirtualKeyboard 2.2]
当shiftActive 或capsLockActive 的true 时,该属性的值为true 。
该属性在 QtQuick.VirtualKeyboard 2.2 版本中引入。
方法文档
void clear()
清除预编辑文本。
void commit()
提交当前预编辑文本。
void commit(string text, int replaceFrom = 0, int replaceLength = 0)
将最终的text 提交到输入项,并可选地修改相对于编辑前文本起始位置的文本。如果replaceFrom不为零,则text 会将replaceFrom位置起始、长度为replaceLength的文本内容替换掉。
void sendKeyClick(int key, string text, int modifiers = 0)
向当前拥有焦点的输入项发送一个键点击事件,该事件的key 、text 和modifiers 参数均为给定值。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.