本页内容

SelectionListModel QML Type (Uncreatable)

为下拉列表提供数据模型。更多...

Import Statement: import QtQuick.VirtualKeyboard
In C++: QVirtualKeyboardSelectionListModel

注意:这是一个不可创建的类型。无法在 QML 中实例化。

信号

方法

详细说明

SelectionListModel 是由输入法提供的词汇候选列表数据模型。

无法直接创建 SelectionListModel 的实例。相反,InputEngine 负责管理这些实例,并通过InputEngine::wordCandidateListModel 属性提供对该模型的访问。

该模型为列表委托提供了以下数据角色:

  • display 项目的显示文本。
  • wordCompletionLength 项目的单词补全长度。
  • dictionaryType 单词的词典类型,详见QVirtualKeyboardSelectionListModel::DictionaryType 。
  • canRemoveSuggestion 一个布尔值,用于指示该单词是否可以从词典中删除。

activeItemChanged 信号指示输入法当前高亮显示的是哪个项目。视图应响应此信号,通过在列表中高亮显示相应项目来做出响应。

用户的选择由selectItem()方法处理。当用户从列表中选择一个项目时,视图应调用此方法。

信号文档

void activeItemChanged(int index)

当列表中的当前选中项发生变化时,会发出此信号。用户界面应响应此信号,将列表中位于index 的项高亮显示。

注意: 相应的处理程序 是onActiveItemChanged 。

void itemSelected(int index)

当用户选中位于index 上的某个项目时,会触发此信号。

注意: 对应的处理程序 为onItemSelected 。

方法文档

void removeItem(int index)

当用户从列表中移除位于位置index 的项时,应调用此方法。该移除操作将转发至输入方法以进行进一步处理。

void selectItem(int index)

当用户从列表中选中位于index 位置的项时,应调用此方法。选中项将转发给输入方法以供进一步处理。

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