QInputMethod 類提供對活動文本輸入法的訪問。 更多...
| 頭: | #include <QInputMethod> |
| qmake: | QT += gui |
| 繼承: | QObject |
| enum | 動作 { Click, ContextMenu } |
|
|
| QRectF | anchorRectangle () const |
| QRectF | cursorRectangle () const |
| Qt::LayoutDirection | inputDirection () const |
| QRectF | inputItemClipRectangle () const |
| QRectF | inputItemRectangle () const |
| QTransform | inputItemTransform () const |
| bool | isAnimating () const |
| bool | isVisible () const |
| QRectF | keyboardRectangle () const |
| QLocale | locale () const |
| void | setInputItemRectangle (const QRectF & rect ) |
| void | setInputItemTransform (const QTransform & transform ) |
| void | setVisible (bool visible ) |
| void | commit () |
| void | hide () |
| void | invokeAction (QInputMethod::Action a , int cursorPosition ) |
| void | reset () |
| void | show () |
| void | update (Qt::InputMethodQueries queries ) |
| void | anchorRectangleChanged () |
| void | animatingChanged () |
| void | cursorRectangleChanged () |
| void | inputDirectionChanged (Qt::LayoutDirection newDirection ) |
| void | inputItemClipRectangleChanged () |
| void | keyboardRectangleChanged () |
| void | localeChanged () |
| void | visibleChanged () |
| QVariant | queryFocusObject (Qt::InputMethodQuery query , QVariant argument ) |
QInputMethod 用於集成平颱文本輸入法的文本編輯器,且更常見的是通過應用程序視圖查詢各種文本輸入法的相關信息 (像:虛擬鍵盤可見性和鍵盤尺度)。
Qt Quick 還提供訪問 QML 中的 QInputMethod 透過
Qt 全局對象
as
Qt.inputMethod
特性。
指示由用戶履行的動作種類。
| 常量 | 值 | 描述 |
|---|---|---|
QInputMethod::Click
|
0
|
正常點擊/敲擊 |
QInputMethod::ContextMenu
|
1
|
上下文菜單點擊/敲擊 (如:右鍵或敲擊並保持) |
另請參閱 invokeAction ().
輸入項在窗口坐標中的錨點矩形。
Anchor rectangle is often used by various text editing controls like text prediction popups for following the text selection.
訪問函數:
| QRectF | anchorRectangle () const |
通知程序信號:
| void | anchorRectangleChanged () |
true 當打開 (或關閉) 虛擬鍵盤時。
動畫為 false 當完全打開 (或關閉) 鍵盤時。當
animating
is
true
and
visibility
is
true
鍵盤正被打開。當
animating
is
true
and
visibility
為 false 鍵盤正被關閉。
訪問函數:
| bool | isAnimating () const |
通知程序信號:
| void | animatingChanged () |
輸入項在窗口坐標中的光標矩形。
Cursor rectangle is often used by various text editing controls like text prediction popups for following the text being typed.
訪問函數:
| QRectF | cursorRectangle () const |
通知程序信號:
| void | cursorRectangleChanged () |
當前輸入方嚮。
訪問函數:
| Qt::LayoutDirection | inputDirection () const |
通知程序信號:
| void | inputDirectionChanged (Qt::LayoutDirection newDirection ) |
輸入項在窗口坐標中的裁剪矩形。
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).
訪問函數:
| QRectF | inputItemClipRectangle () const |
通知程序信號:
| void | inputItemClipRectangleChanged () |
虛擬鍵盤在窗口坐標中的幾何體。
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.
訪問函數:
| QRectF | keyboardRectangle () const |
通知程序信號:
| void | keyboardRectangleChanged () |
當前輸入區域設置。
訪問函數:
| QLocale | locale () const |
通知程序信號:
| void | localeChanged () |
虛擬鍵盤在屏幕上的可見性
Input method visibility remains false for devices with no virtual keyboards.
訪問函數:
| bool | isVisible () const |
通知程序信號:
| void | visibleChanged () |
[slot]
void
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 commit() function, for example when the cursor is moved elsewhere.
[slot]
void
QInputMethod::
hide
()
請求關閉虛擬鍵盤。
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.
[slot]
void
QInputMethod::
invokeAction
(
QInputMethod::Action
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 和給定 cursorPosition . Input methods often use this information to offer more word suggestions to the user.
[slot]
void
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.
輸入法自動重置,當聚焦編輯器改變時。
[slot]
void
QInputMethod::
show
()
請求打開虛擬鍵盤。若平颱不提供虛擬鍵盤,可見性仍然為 false。
Normally applications should not need to call this function, keyboard should automatically open when the text editor gains focus.
[slot]
void
QInputMethod::
update
(
Qt::InputMethodQueries
queries
)
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.
返迴在輸入項坐標中的輸入項幾何體。
該函數在 Qt 5.1 引入。
另請參閱 setInputItemRectangle ().
返迴從輸入項坐標到窗口坐標的變換。
另請參閱 setInputItemTransform ().
[static]
QVariant
QInputMethod::
queryFocusObject
(
Qt::InputMethodQuery
query
,
QVariant
argument
)
發送 query 到當前聚焦對象采用參數 argument 並返迴結果。
把輸入項的幾何體設為 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.
該函數在 Qt 5.1 引入。
另請參閱 inputItemRectangle ().
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.
另請參閱 inputItemTransform ().
控製鍵盤的可見性。相當於調用
show
() (若
visible
is
true
) 或
hide
() (若
visible
is
false
).