本页内容

QAccessibleSelectionInterface Class

QAccessibleSelectionInterface 类实现了对选择处理的支持。更多内容...

头文件: #include <QAccessibleSelectionInterface>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
自: Qt 6.5

公共函数

QAccessibleSelectionInterface()
virtual ~QAccessibleSelectionInterface()
virtual bool clear() = 0
virtual bool isSelected(QAccessibleInterface *childItem) const
virtual bool select(QAccessibleInterface *childItem) = 0
virtual bool selectAll() = 0
virtual QAccessibleInterface *selectedItem(int selectionIndex) const
virtual int selectedItemCount() const = 0
virtual QList<QAccessibleInterface *> selectedItems() const = 0
virtual bool unselect(QAccessibleInterface *childItem) = 0

详细说明

它提供了用于检索当前选择以及修改选择的方法。

仅支持直接子节点的选择。

成员函数文档

[constexpr noexcept default] QAccessibleSelectionInterface::QAccessibleSelectionInterface()

默认——构造一个QAccessibleSelectionInterface 的实例。

[virtual noexcept] QAccessibleSelectionInterface::~QAccessibleSelectionInterface()

销毁QAccessibleSelectionInterface 。

[pure virtual] bool QAccessibleSelectionInterface::clear()

取消选中所有可访问的子项目。

返回所有可访问的子项是否已实际从选择中移除,即调用此方法后,选择集是否为空。

[virtual] bool QAccessibleSelectionInterface::isSelected(QAccessibleInterface *childItem) const

返回childItem 是否属于当前选中项。

默认实现会检查childItem 是否包含在由QAccessibleSelectionInterface::selectedItems 获取的项目列表中。

[pure virtual] bool QAccessibleSelectionInterface::select(QAccessibleInterface *childItem)

将childItem 添加到选集中。返回childItem 是否已实际添加到选集中。

对于仅允许单选的实现,此操作可能会替换当前的选择项。

[pure virtual] bool QAccessibleSelectionInterface::selectAll()

选择所有可访问的子项。

返回所有可访问的子项是否已实际添加到选择中。

[virtual] QAccessibleInterface *QAccessibleSelectionInterface::selectedItem(int selectionIndex) const

返回选区中索引为selectionIndex 的选定可访问项目。

请注意,该索引指的是第 n 个选中的可访问项目(即当前选中项中的索引),这通常与为获取同一项目而传递给QAccessibleInterface::child() 的索引不同。

默认实现使用selectionIndex 从QAccessibleSelectionInterface::selectedItems() 返回的已选项目列表中检索该项目。

特别是对于需要处理大量选中项的实现,出于性能考虑,可能需要以更高效的方式重写此方法。

[pure virtual] int QAccessibleSelectionInterface::selectedItemCount() const

返回所选可访问项的总数。

[pure virtual] QList<QAccessibleInterface *> QAccessibleSelectionInterface::selectedItems() const

返回所选可访问项目的列表。

[pure virtual] bool QAccessibleSelectionInterface::unselect(QAccessibleInterface *childItem)

将“childItem ”从选择集中移除。

返回该可访问项目是否已实际从选择集中移除。

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