QVirtualKeyboardInputContext Class
提供对输入上下文的访问。更多...
| 标题: | #include <QVirtualKeyboardInputContext> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS VirtualKeyboard) target_link_libraries(mytarget PRIVATE Qt6::VirtualKeyboard) |
| qmake: | QT += virtualkeyboard |
| 在 QML 中: | InputContext |
| 继承自: | QObject |
属性
|
|
公共函数
| int | anchorPosition() const |
| bool | anchorRectIntersectsClipRect() const |
| QRectF | anchorRectangle() const |
| void | clear() |
| void | commit() |
| void | commit(const QString &text, int replaceFrom = 0, int replaceLength = 0) |
| int | cursorPosition() const |
| bool | cursorRectIntersectsClipRect() const |
| QRectF | cursorRectangle() const |
| QVirtualKeyboardInputEngine * | inputEngine() const |
| Qt::InputMethodHints | inputMethodHints() const |
| bool | isAnimating() const |
| bool | isCapsLockActive() const |
| bool | isSelectionControlVisible() const |
| bool | isShiftActive() const |
| bool | isUppercase() const |
| QVirtualKeyboardObserver * | keyboardObserver() const |
| QString | locale() const |
| QString | preeditText() const |
| QString | selectedText() const |
| void | sendKeyClick(int key, const QString &text, int modifiers = 0) |
| void | setAnimating(bool isAnimating) |
| void | setPreeditText(const QString &text, QList<QInputMethodEvent::Attribute> attributes = QList<QInputMethodEvent::Attribute>(), int replaceFrom = 0, int replaceLength = 0) |
| QString | surroundingText() const |
信号
| void | anchorPositionChanged() |
| void | anchorRectIntersectsClipRectChanged() |
| void | anchorRectangleChanged() |
| void | animatingChanged() |
| void | capsLockActiveChanged() |
| void | cursorPositionChanged() |
| void | cursorRectIntersectsClipRectChanged() |
| void | cursorRectangleChanged() |
| void | inputMethodHintsChanged() |
| void | localeChanged() |
| void | preeditTextChanged() |
| void | selectedTextChanged() |
| void | selectionControlVisibleChanged() |
| void | shiftActiveChanged() |
| void | surroundingTextChanged() |
| void | uppercaseChanged() |
属性文档
[read-only] anchorPosition : int
该属性存储锚点位置。
当锚点位置发生变化时,该属性也会随之改变。
访问函数:
| int | anchorPosition() const |
通知信号:
| void | anchorPositionChanged() |
[read-only] anchorRectIntersectsClipRect : bool
如果选择锚点的边界矩形与暴露的输入项矩形相交,则返回true 。
访问函数:
| bool | anchorRectIntersectsClipRect() const |
通知信号:
| void | anchorRectIntersectsClipRectChanged() |
另请参阅 Qt::ImAnchorRectangle 和Qt::ImInputItemClipRectangle 。
[read-only] anchorRectangle : QRectF
该属性存储锚点矩形。
当锚点矩形发生变化时,该属性也会随之改变。
访问函数:
| QRectF | anchorRectangle() const |
通知信号:
| void | anchorRectangleChanged() |
animating : bool
该属性用于存储动画状态。
使用此属性可设置动画状态,例如在 UI 状态过渡期间。
访问函数:
| bool | isAnimating() const |
| void | setAnimating(bool isAnimating) |
通知器信号:
| void | animatingChanged() |
[read-only] capsLockActive : bool
该属性保存大写锁定状态。
当大写锁定状态发生变化时,该属性也会随之改变。
访问函数:
| bool | isCapsLockActive() const |
通知信号:
| void | capsLockActiveChanged() |
[read-only] cursorPosition : int
该属性保存光标位置。
当光标位置发生变化时,该属性也会随之改变。
访问函数:
| int | cursorPosition() const |
通知信号:
| void | cursorPositionChanged() |
[read-only] cursorRectIntersectsClipRect : bool
如果输入光标的边界矩形与暴露的输入项矩形发生相交,则返回true 。
访问函数:
| bool | cursorRectIntersectsClipRect() const |
通知信号:
| void | cursorRectIntersectsClipRectChanged() |
另请参阅 Qt::ImCursorRectangle 和Qt::ImInputItemClipRectangle 。
[read-only] cursorRectangle : QRectF
该属性存储光标矩形。
当光标矩形发生变化时,该属性也会随之改变。
访问函数:
| QRectF | cursorRectangle() const |
通知信号:
| void | cursorRectangleChanged() |
[read-only] inputEngine : QVirtualKeyboardInputEngine* const
该属性存储输入引擎。
该属性存储输入引擎。
访问函数:
| QVirtualKeyboardInputEngine * | inputEngine() const |
[read-only] inputMethodHints : Qt::InputMethodHints
该属性用于存储输入法提示。
当输入法提示发生变化时,该属性也会随之变化。
访问函数:
| Qt::InputMethodHints | inputMethodHints() const |
通知信号:
| void | inputMethodHintsChanged() |
[read-only, since 6.1] keyboardObserver : QVirtualKeyboardObserver* const
保存键盘观察者对象,可用于接收键盘变化事件的通知。
该枚举类型在 Qt 6.1 中引入。
访问函数:
| QVirtualKeyboardObserver * | keyboardObserver() const |
[read-only] locale : QString
该属性存储区域设置。
当输入区域设置发生变化时,该属性也会随之改变。
访问函数:
| QString | locale() const |
通知信号:
| void | localeChanged() |
preeditText : QString
此属性用于存储编辑前的文本。
此属性用于设置编辑前的文本。
访问函数:
| QString | preeditText() const |
| void | setPreeditText(const QString &text, QList<QInputMethodEvent::Attribute> attributes = QList<QInputMethodEvent::Attribute>(), int replaceFrom = 0, int replaceLength = 0) |
通知信号:
| void | preeditTextChanged() |
[read-only] selectedText : QString
该属性用于存储所选文本。
当选中文字发生变化时,该属性也会随之改变。
访问函数:
| QString | selectedText() const |
通知信号:
| void | selectedTextChanged() |
[read-only] selectionControlVisible : bool
如果选择控件当前可见,则返回true 。
访问函数:
| bool | isSelectionControlVisible() const |
通知信号:
| void | selectionControlVisibleChanged() |
[read-only] shiftActive : bool
该属性用于存储轮班状态。
当班次状态发生变化时,该属性也会随之改变。
访问函数:
| bool | isShiftActive() const |
通知信号:
| void | shiftActiveChanged() |
[read-only] surroundingText : QString
该属性存储光标周围的文本。
当光标周围的文本发生变化时,该属性也会随之改变。
访问函数:
| QString | surroundingText() const |
通知信号:
| void | surroundingTextChanged() |
[read-only] uppercase : bool
该属性用于标识是否为大写。
当shiftActive 或capsLockActive 的true 为真时,该属性的值为true 。
访问函数:
| bool | isUppercase() const |
通知信号:
| void | uppercaseChanged() |
成员函数文档
[invokable] void QVirtualKeyboardInputContext::clear()
清除预编辑文本。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QVirtualKeyboardInputContext::commit()
提交当前预编辑文本。
注意:此 函数可通过元对象系统和 QML 调用。参见Q_INVOKABLE 。
[invokable] void QVirtualKeyboardInputContext::commit(const QString &text, int replaceFrom = 0, int replaceLength = 0)
将最终的text 提交到输入项,并可选地相对于预编辑文本的起始位置修改文本。如果replaceFrom 不为零,则text 会将replaceFrom 起始位置开始、长度为replaceLength 的内容替换掉。
注意: 可以通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QVirtualKeyboardInputContext::sendKeyClick(int key, const QString &text, int modifiers = 0)
向当前拥有焦点的输入项发送一个键点击事件,该事件的key 、text 和modifiers 参数均为给定值。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
© 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.