用于输入法的基类。 更多...
头: | #include <QVirtualKeyboardAbstractInputMethod> |
CMake: |
find_package(Qt6 COMPONENTS VirtualKeyboard REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::VirtualKeyboard) |
qmake: | QT += virtualkeyboard |
继承: | QObject |
QVirtualKeyboardAbstractInputMethod (QObject * parent = nullptr) | |
virtual | ~QVirtualKeyboardAbstractInputMethod () |
virtual bool | clickPreeditText (int cursorPosition ) |
QVirtualKeyboardInputContext * | inputContext () const |
QVirtualKeyboardInputEngine * | inputEngine () const |
virtual QList<QVirtualKeyboardInputEngine::InputMode> | inputModes (const QString & locale ) = 0 |
virtual bool | keyEvent (Qt::Key key , const QString & text , Qt::KeyboardModifiers modifiers ) = 0 |
virtual QList<QVirtualKeyboardInputEngine::PatternRecognitionMode> | patternRecognitionModes () const |
virtual bool | reselect (int cursorPosition , const QVirtualKeyboardInputEngine::ReselectFlags & reselectFlags ) |
virtual QVariant | selectionListData (QVirtualKeyboardSelectionListModel::Type type , int index , QVirtualKeyboardSelectionListModel::Role role ) |
virtual int | selectionListItemCount (QVirtualKeyboardSelectionListModel::Type type ) |
virtual void | selectionListItemSelected (QVirtualKeyboardSelectionListModel::Type type , int index ) |
virtual bool | selectionListRemoveItem (QVirtualKeyboardSelectionListModel::Type type , int index ) |
virtual QList<QVirtualKeyboardSelectionListModel::Type> | selectionLists () |
virtual bool | setInputMode (const QString & locale , QVirtualKeyboardInputEngine::InputMode inputMode ) = 0 |
virtual bool | setTextCase (QVirtualKeyboardInputEngine::TextCase textCase ) = 0 |
virtual QVirtualKeyboardTrace * | traceBegin (int traceId , QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode , const QVariantMap & traceCaptureDeviceInfo , const QVariantMap & traceScreenInfo ) |
virtual bool | traceEnd (QVirtualKeyboardTrace * trace ) |
virtual void | clearInputMode () |
virtual void | reset () |
virtual void | update () |
void | selectionListActiveItemChanged (QVirtualKeyboardSelectionListModel::Type type , int index ) |
void | selectionListChanged (QVirtualKeyboardSelectionListModel::Type type ) |
void | selectionListsChanged () |
使用此类,若想要使用 C/C++ 语言实现自定义输入法。
构造输入法采用 parent .
[virtual slot, since QtQuick.VirtualKeyboard 6.1]
void
QVirtualKeyboardAbstractInputMethod::
clearInputMode
()
Clears input mode.
This method is called by the virtual keyboard when this input method is being replaced by another input method. It should clear the operations performed by setInputMode () method, for example, to disconnect signal handlers from the virtual keyboard or free up resources.
The input mode may be reactivated by calling setInputMode (). However, note that the calls to setInputMethod() and clearInputMethod() are not in balance. Thus, for example, setInputMethod() may be called multiple times without matching calls to clearInputMethod().
默认实现什么都不做。
This function was introduced in QtQuick.VirtualKeyboard 6.1.
[virtual slot]
void
QVirtualKeyboardAbstractInputMethod::
reset
()
This method is called by the input engine when the input method needs to be reset. The input method must reset its internal state only. The main difference to the update () method is that reset() modifies only the input method state, i.e. it must not modify the input context.
[signal]
void
QVirtualKeyboardAbstractInputMethod::
selectionListActiveItemChanged
(
QVirtualKeyboardSelectionListModel::Type
type
,
int
index
)
输入法会发射此信号当当前 index 已改变在选定列表标识通过 type .
[signal]
void
QVirtualKeyboardAbstractInputMethod::
selectionListChanged
(
QVirtualKeyboardSelectionListModel::Type
type
)
The input method emits this signal when the contents of the selection list has changed. The type parameter specifies which selection list has changed.
[signal, since QtQuick.VirtualKeyboard 2.2]
void
QVirtualKeyboardAbstractInputMethod::
selectionListsChanged
()
The input method emits this signal when the selection list types have changed. This signal will trigger a call to selectionLists () method, allowing the input method to update the selection list types.
该函数在 QtQuick.VirtualKeyboard 2.2 引入。
[virtual slot]
void
QVirtualKeyboardAbstractInputMethod::
update
()
This method is called by the input engine when the input method needs to be updated. The input method must close the current pre-edit text and restore its internal state to the default.
[虚拟]
QVirtualKeyboardAbstractInputMethod::
~QVirtualKeyboardAbstractInputMethod
()
销毁输入法并释放所有分配资源。
[virtual, since QtQuick.VirtualKeyboard 2.4]
bool
QVirtualKeyboardAbstractInputMethod::
clickPreeditText
(
int
cursorPosition
)
调用当用户点击预编辑文本在 cursorPosition .
函数应返回
true
若它处理事件。否则输入会回退到
reselect
() 为进一步处理。
该函数在 QtQuick.VirtualKeyboard 2.4 引入。
返回输入法关联的输入上下文。此方法返回
NULL
若输入法不活动。
返回输入法关联的输入引擎。此方法返回
NULL
若输入法不活动。
[pure virtual]
QList
<
QVirtualKeyboardInputEngine::InputMode
> QVirtualKeyboardAbstractInputMethod::
inputModes
(const
QString
&
locale
)
返回输入方式的列表为 locale .
[pure virtual]
bool
QVirtualKeyboardAbstractInputMethod::
keyEvent
(
Qt::Key
key
, const
QString
&
text
,
Qt::KeyboardModifiers
modifiers
)
此方法的目的是, 处理由输入引擎生成的键事件。
key parameter specifies the code of the key to handle. The key code does not distinguish between capital and non-capital letters. The text parameter contains the Unicode text for the key. The modifiers parameter contains the key modifiers that apply to key.
此方法返回
true
if the key event was successfully handled. If the return value is
false
, the key event is redirected to the default input method for further processing.
[virtual, since QtQuick.VirtualKeyboard 2.0]
QList
<
QVirtualKeyboardInputEngine::PatternRecognitionMode
> QVirtualKeyboardAbstractInputMethod::
patternRecognitionModes
() const
返回支持模式识别方式的列表。
输入引擎调用此方法,以查询支持的模式识别方式列表。
该函数在 QtQuick.VirtualKeyboard 2.0 引入。
[virtual, since QtQuick.VirtualKeyboard 2.0]
bool
QVirtualKeyboardAbstractInputMethod::
reselect
(
int
cursorPosition
, const
QVirtualKeyboardInputEngine::ReselectFlags
&
reselectFlags
)
此函数试图重选的单词位于 cursorPosition 。 reselectFlags 定义应如何选择光标位置相关单词的规则。
函数返回
true
若单词被成功重选。
该函数在 QtQuick.VirtualKeyboard 2.0 引入。
[虚拟]
QVariant
QVirtualKeyboardAbstractInputMethod::
selectionListData
(
QVirtualKeyboardSelectionListModel::Type
type
,
int
index
,
QVirtualKeyboardSelectionListModel::Role
role
)
返回选定列表项数据标识通过 type 。 role 参数指定请求何种数据。 index 参数是列表从 0 开始的索引。
[虚拟]
int
QVirtualKeyboardAbstractInputMethod::
selectionListItemCount
(
QVirtualKeyboardSelectionListModel::Type
type
)
返回选定列表项数标识通过 type .
[虚拟]
void
QVirtualKeyboardAbstractInputMethod::
selectionListItemSelected
(
QVirtualKeyboardSelectionListModel::Type
type
,
int
index
)
此方法被调用当项位于 index 被用户选中。选定列表的标识是通过 type 参数。
[虚拟]
bool
QVirtualKeyboardAbstractInputMethod::
selectionListRemoveItem
(
QVirtualKeyboardSelectionListModel::Type
type
,
int
index
)
此方法被调用当项位于
index
必须被移除从字典。选定列表的标识是通过
type
参数。函数返回
true
若单词被成功移除。
[虚拟]
QList
<
QVirtualKeyboardSelectionListModel::Type
> QVirtualKeyboardAbstractInputMethod::
selectionLists
()
返回用于此输入法的选定列表的列表。
此方法由输入引擎调用,当输入法被激活且每次更新输入法提示时。输入法可以预留选定列表,通过返回期望的选定列表类型。
输入法可以请求输入引擎随时更新选定列表通过发射 selectionListsChanged () 信号。此信号由此方法的调用所触发,允许输入法更新选定列表类型。
[pure virtual]
bool
QVirtualKeyboardAbstractInputMethod::
setInputMode
(const
QString
&
locale
,
QVirtualKeyboardInputEngine::InputMode
inputMode
)
设置
inputMode
and
locale
为此输入法。返回
true
若成功。
[pure virtual]
bool
QVirtualKeyboardAbstractInputMethod::
setTextCase
(
QVirtualKeyboardInputEngine::TextCase
textCase
)
更新
textCase
为此输入法。方法返回
true
若成功。
[virtual, since QtQuick.VirtualKeyboard 2.0]
QVirtualKeyboardTrace
*QVirtualKeyboardAbstractInputMethod::
traceBegin
(
int
traceId
,
QVirtualKeyboardInputEngine::PatternRecognitionMode
patternRecognitionMode
, const
QVariantMap
&
traceCaptureDeviceInfo
, const
QVariantMap
&
traceScreenInfo
)
此方法被调用当开始跟踪交互采用指定 patternRecognitionMode 。跟踪的唯一标识是通过 traceId 。 traceCaptureDeviceInfo 提供源设备的有关信息和 traceScreenInfo 提供屏幕上下文的有关信息。
若输入法接受事件且想要捕获跟踪输入,它必须返回新的 QVirtualKeyboardTrace 对象。此对象必须保持有效直到 traceEnd () 方法被调用。若 QVirtualKeyboardTrace 被渲染在屏幕中,它仍然在那里直到 QVirtualKeyboardTrace 对象被销毁。
该函数在 QtQuick.VirtualKeyboard 2.0 引入。
[virtual, since QtQuick.VirtualKeyboard 2.0]
bool
QVirtualKeyboardAbstractInputMethod::
traceEnd
(
QVirtualKeyboardTrace
*
trace
)
此方法被调用,当跟踪交互结束时。输入法应销毁 trace 对象在某个时刻,在调用此函数后。见 用于输入法的跟踪 API 如何访问聚合数据。
方法返回
true
如果接受跟踪交互。
该函数在 QtQuick.VirtualKeyboard 2.0 引入。