QAbstractItemView 类为项视图类提供基本功能。 更多...
头: | #include <QAbstractItemView> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
继承: | QAbstractScrollArea |
继承者: |
QColumnView , QHeaderView , QListView , QTableView ,和 QTreeView |
enum | DragDropMode { NoDragDrop, DragOnly, DropOnly, DragDrop, InternalMove } |
enum | EditTrigger { NoEditTriggers, CurrentChanged, DoubleClicked, SelectedClicked, EditKeyPressed, …, AllEditTriggers } |
flags | EditTriggers |
enum | ScrollHint { EnsureVisible, PositionAtTop, PositionAtBottom, PositionAtCenter } |
enum | ScrollMode { ScrollPerItem, ScrollPerPixel } |
enum | SelectionBehavior { SelectItems, SelectRows, SelectColumns } |
enum | SelectionMode { SingleSelection, ContiguousSelection, ExtendedSelection, MultiSelection, NoSelection } |
|
|
QAbstractItemView (QWidget * parent = nullptr) | |
virtual | ~QAbstractItemView () |
bool | alternatingRowColors () const |
int | autoScrollMargin () const |
void | closePersistentEditor (const QModelIndex & index ) |
QModelIndex | currentIndex () const |
Qt::DropAction | defaultDropAction () const |
QAbstractItemView::DragDropMode | dragDropMode () const |
bool | dragDropOverwriteMode () const |
bool | dragEnabled () const |
QAbstractItemView::EditTriggers | editTriggers () const |
bool | hasAutoScroll () const |
QAbstractItemView::ScrollMode | horizontalScrollMode () const |
QSize | iconSize () const |
virtual QModelIndex | indexAt (const QPoint & point ) const = 0 |
QWidget * | indexWidget (const QModelIndex & index ) const |
bool | isPersistentEditorOpen (const QModelIndex & index ) const |
QAbstractItemDelegate * | itemDelegate () const |
QAbstractItemDelegate * | itemDelegateForColumn (int column ) const |
virtual QAbstractItemDelegate * | itemDelegateForIndex (const QModelIndex & index ) const |
QAbstractItemDelegate * | itemDelegateForRow (int row ) const |
virtual void | keyboardSearch (const QString & search ) |
QAbstractItemModel * | model () const |
void | openPersistentEditor (const QModelIndex & index ) |
void | resetHorizontalScrollMode () |
void | resetVerticalScrollMode () |
QModelIndex | rootIndex () const |
virtual void | scrollTo (const QModelIndex & index , QAbstractItemView::ScrollHint hint = EnsureVisible) = 0 |
QAbstractItemView::SelectionBehavior | selectionBehavior () const |
QAbstractItemView::SelectionMode | selectionMode () const |
QItemSelectionModel * | selectionModel () const |
void | setAlternatingRowColors (bool enable ) |
void | setAutoScroll (bool enable ) |
void | setAutoScrollMargin (int margin ) |
void | setDefaultDropAction (Qt::DropAction dropAction ) |
void | setDragDropMode (QAbstractItemView::DragDropMode behavior ) |
void | setDragDropOverwriteMode (bool overwrite ) |
void | setDragEnabled (bool enable ) |
void | setDropIndicatorShown (bool enable ) |
void | setEditTriggers (QAbstractItemView::EditTriggers triggers ) |
void | setHorizontalScrollMode (QAbstractItemView::ScrollMode mode ) |
void | setIconSize (const QSize & size ) |
void | setIndexWidget (const QModelIndex & index , QWidget * widget ) |
void | setItemDelegate (QAbstractItemDelegate * delegate ) |
void | setItemDelegateForColumn (int column , QAbstractItemDelegate * delegate ) |
void | setItemDelegateForRow (int row , QAbstractItemDelegate * delegate ) |
virtual void | setModel (QAbstractItemModel * model ) |
void | setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior ) |
void | setSelectionMode (QAbstractItemView::SelectionMode mode ) |
virtual void | setSelectionModel (QItemSelectionModel * selectionModel ) |
void | setTabKeyNavigation (bool enable ) |
void | setTextElideMode (Qt::TextElideMode mode ) |
void | setVerticalScrollMode (QAbstractItemView::ScrollMode mode ) |
bool | showDropIndicator () const |
virtual int | sizeHintForColumn (int column ) const |
QSize | sizeHintForIndex (const QModelIndex & index ) const |
virtual int | sizeHintForRow (int row ) const |
bool | tabKeyNavigation () const |
Qt::TextElideMode | textElideMode () const |
QAbstractItemView::ScrollMode | verticalScrollMode () const |
virtual QRect | visualRect (const QModelIndex & index ) const = 0 |
virtual QVariant | inputMethodQuery (Qt::InputMethodQuery query ) const override |
void | clearSelection () |
void | edit (const QModelIndex & index ) |
virtual void | reset () |
void | scrollToBottom () |
void | scrollToTop () |
virtual void | selectAll () |
void | setCurrentIndex (const QModelIndex & index ) |
virtual void | setRootIndex (const QModelIndex & index ) |
void | update (const QModelIndex & index ) |
void | activated (const QModelIndex & index ) |
void | clicked (const QModelIndex & index ) |
void | doubleClicked (const QModelIndex & index ) |
void | entered (const QModelIndex & index ) |
void | iconSizeChanged (const QSize & size ) |
void | pressed (const QModelIndex & index ) |
void | viewportEntered () |
enum | CursorAction { MoveUp, MoveDown, MoveLeft, MoveRight, MoveHome, …, MovePrevious } |
enum | DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport } |
enum | State { NoState, DraggingState, DragSelectingState, EditingState, ExpandingState, …, AnimatingState } |
QPoint | dirtyRegionOffset () const |
QAbstractItemView::DropIndicatorPosition | dropIndicatorPosition () const |
virtual bool | edit (const QModelIndex & index , QAbstractItemView::EditTrigger trigger , QEvent * event ) |
void | executeDelayedItemsLayout () |
virtual int | horizontalOffset () const = 0 |
virtual void | initViewItemOption (QStyleOptionViewItem * option ) const |
virtual bool | isIndexHidden (const QModelIndex & index ) const = 0 |
virtual QModelIndex | moveCursor (QAbstractItemView::CursorAction cursorAction , Qt::KeyboardModifiers modifiers ) = 0 |
void | scheduleDelayedItemsLayout () |
void | scrollDirtyRegion (int dx , int dy ) |
virtual QModelIndexList | selectedIndexes () const |
virtual QItemSelectionModel::SelectionFlags | selectionCommand (const QModelIndex & index , const QEvent * event = nullptr) const |
void | setDirtyRegion (const QRegion & region ) |
virtual void | setSelection (const QRect & rect , QItemSelectionModel::SelectionFlags flags ) = 0 |
void | setState (QAbstractItemView::State state ) |
virtual void | startDrag (Qt::DropActions supportedActions ) |
QAbstractItemView::State | state () const |
virtual int | verticalOffset () const = 0 |
virtual QRegion | visualRegionForSelection (const QItemSelection & selection ) const = 0 |
virtual void | dragEnterEvent (QDragEnterEvent * event ) override |
virtual void | dragLeaveEvent (QDragLeaveEvent * event ) override |
virtual void | dragMoveEvent (QDragMoveEvent * event ) override |
virtual void | dropEvent (QDropEvent * event ) override |
virtual bool | event (QEvent * event ) override |
virtual bool | eventFilter (QObject * object , QEvent * event ) override |
virtual void | focusInEvent (QFocusEvent * event ) override |
virtual bool | focusNextPrevChild (bool next ) override |
virtual void | focusOutEvent (QFocusEvent * event ) override |
virtual void | inputMethodEvent (QInputMethodEvent * event ) override |
virtual void | keyPressEvent (QKeyEvent * event ) override |
virtual void | mouseDoubleClickEvent (QMouseEvent * event ) override |
virtual void | mouseMoveEvent (QMouseEvent * event ) override |
virtual void | mousePressEvent (QMouseEvent * event ) override |
virtual void | mouseReleaseEvent (QMouseEvent * event ) override |
virtual void | resizeEvent (QResizeEvent * event ) override |
virtual void | timerEvent (QTimerEvent * event ) override |
virtual bool | viewportEvent (QEvent * event ) override |
virtual QSize | viewportSizeHint () const override |
virtual void | closeEditor (QWidget * editor , QAbstractItemDelegate::EndEditHint hint ) |
virtual void | commitData (QWidget * editor ) |
virtual void | currentChanged (const QModelIndex & current , const QModelIndex & previous ) |
virtual void | dataChanged (const QModelIndex & topLeft , const QModelIndex & bottomRight , const QList<int> & roles = QList<int>()) |
virtual void | editorDestroyed (QObject * editor ) |
virtual void | rowsAboutToBeRemoved (const QModelIndex & parent , int start , int end ) |
virtual void | rowsInserted (const QModelIndex & parent , int start , int end ) |
virtual void | selectionChanged (const QItemSelection & selected , const QItemSelection & deselected ) |
virtual void | updateGeometries () |
QAbstractItemView 类是每个标准视图的基类使用 QAbstractItemModel 。QAbstractItemView 是本身不可以被实例化的抽象类。它提供透过信号和槽机制与模型进行互操作的标准接口,使子类能够随着其模型的改变保持最新。此类为键盘和鼠标导航、视口卷动、项编辑及选定提供标准支持。键盘导航实现了此功能:
键 | 功能 |
---|---|
方向键 | 改变当前项并选择它。 |
Ctrl + 方向键 | 改变当前项但不选择它。 |
Shift + 方向键 | 更改当前项并选择它。先前选中项不会被取消选择。 |
Ctrl+Space | 触发当前项的选定。 |
Tab/Backtab | 将当前项更改为下一/上一项。 |
Home/End | 选择模型中的第一/最后项。 |
Page up/Page down | 按视图中的可见行数向上/向下卷动展示行。 |
Ctrl+A | 选择模型中的所有项。 |
注意,上表假定 选定模式 允许操作。例如,无法选择项,若选定模式为 QAbstractItemView::NoSelection .
QAbstractItemView 类是一种 模型/视图类 且属于 Qt 的 模型/视图框架 .
视图类继承 QAbstractItemView 只需要实现自己的特定视图功能,譬如绘制项、返回项几何体、查找项、等。
QAbstractItemView 提供常见槽,譬如 edit () 和 setCurrentIndex ()。还提供很多保护槽,包括 dataChanged (), rowsInserted (), rowsAboutToBeRemoved (), selectionChanged (),和 currentChanged ().
根项的返回通过 rootIndex (),和当前项通过 currentIndex ()。要确保项可见使用 scrollTo ().
某些 QAbstractItemView 函数涉及卷动,例如 setHorizontalScrollMode () 和 setVerticalScrollMode ()。要设置滚动条的范围,例如,可以重实现视图的 resizeEvent () 函数:
void MyView::resizeEvent(QResizeEvent *event) { horizontalScrollBar()->setRange(0, realWidth - width()); ... }
注意,范围不更新,直到小部件被展示为止。
几个其它函数涉及选定控制;例如 setSelectionMode (),和 setSelectionBehavior ()。此类为处理提供默认选定模型 ( selectionModel ()),但可以替换这通过使用 setSelectionModel () 采用实例 QItemSelectionModel .
要完全控制项的显示和编辑,可以指定委托采用 setItemDelegate ().
QAbstractItemView 提供了许多保护函数。某些涉及编辑,例如, edit (),和 commitData (),而其它的是键盘和鼠标事件处理程序。
注意: 若继承 QAbstractItemView 并打算更新视口内容,应使用 viewport-> update () 而不是 update () 因为所有描绘操作都发生在视口中。
另请参阅 视图类 , 模型/视图编程 ,和 QAbstractItemModel .
此枚举描述在项之间导航的不同方式,
常量 | 值 | 描述 |
---|---|---|
QAbstractItemView::MoveUp
|
0
|
移至当前项的上方项。 |
QAbstractItemView::MoveDown
|
1
|
移至当前项的下方项。 |
QAbstractItemView::MoveLeft
|
2
|
移至当前项的项左侧。 |
QAbstractItemView::MoveRight
|
3
|
移至当前项的项右侧。 |
QAbstractItemView::MoveHome
|
4
|
移至左上角项。 |
QAbstractItemView::MoveEnd
|
5
|
移至右下角项。 |
QAbstractItemView::MovePageUp
|
6
|
移至当前项上一页。 |
QAbstractItemView::MovePageDown
|
7
|
移至当前项下一页。 |
QAbstractItemView::MoveNext
|
8
|
移至当前项之后项。 |
QAbstractItemView::MovePrevious
|
9
|
移至当前项之前项。 |
另请参阅 moveCursor ().
描述视图可以行动的各种拖放事件。默认情况下,视图不支持拖曳或掉落 (
NoDragDrop
).
常量 | 值 | 描述 |
---|---|---|
QAbstractItemView::NoDragDrop
|
0
|
不支持拖曳或掉落。 |
QAbstractItemView::DragOnly
|
1
|
视图支持拖曳自己的项 |
QAbstractItemView::DropOnly
|
2
|
视图接受掉落 |
QAbstractItemView::DragDrop
|
3
|
视图支持拖拽和掉落两者 |
QAbstractItemView::InternalMove
|
4
|
视图接受移动 ( 非拷贝 ) 操作仅来自自身。 |
注意,使用模型需要提供对拖放操作的支持。
另请参阅 setDragDropMode () 和 将拖放用于项视图 .
此枚举指示掉落指示器相对当前鼠标位置的索引位置:
常量 | 值 | 描述 |
---|---|---|
QAbstractItemView::OnItem
|
0
|
项将掉落在索引处。 |
QAbstractItemView::AboveItem
|
1
|
项将掉落在索引上方。 |
QAbstractItemView::BelowItem
|
2
|
项将掉落在索引下方。 |
QAbstractItemView::OnViewport
|
3
|
项将掉落在没有项的视口区域。各视图处理视口掉落项的方式,从属正使用的底层模型行为。 |
此枚举描述初启项将编辑的动作。
常量 | 值 | 描述 |
---|---|---|
QAbstractItemView::NoEditTriggers
|
0
|
没有编辑可能。 |
QAbstractItemView::CurrentChanged
|
1
|
开始编辑每当当前项改变时。 |
QAbstractItemView::DoubleClicked
|
2
|
开始编辑当双击项时。 |
QAbstractItemView::SelectedClicked
|
4
|
开始编辑当点击已选中项时。 |
QAbstractItemView::EditKeyPressed
|
8
|
开始编辑当在项上按下平台编辑键时。 |
QAbstractItemView::AnyKeyPressed
|
16
|
开始编辑当在项上按下任意键时。 |
QAbstractItemView::AllEditTriggers
|
31
|
开始编辑对于上述所有动作。 |
EditTriggers 类型是 typedef 对于 QFlags <EditTrigger>。它存储 EditTrigger 值的 OR 组合。
常量 | 值 | 描述 |
---|---|---|
QAbstractItemView::EnsureVisible
|
0
|
卷动以确保项可见。 |
QAbstractItemView::PositionAtTop
|
1
|
卷动以将项放置在视口顶部。 |
QAbstractItemView::PositionAtBottom
|
2
|
卷动以定位到视口底部项。 |
QAbstractItemView::PositionAtCenter
|
3
|
卷动以定位到视口中心项。 |
描述滚动条的行为应如何。当把卷动模式设为 ScrollPerPixel 时,将自动调节单步大小,除非它被明确设置使用 setSingleStep ()。可以通过将单步大小设为 -1 以还原自动调节。
常量 | 值 | 描述 |
---|---|---|
QAbstractItemView::ScrollPerItem
|
0
|
视图每次卷动内容一项。 |
QAbstractItemView::ScrollPerPixel
|
1
|
视图每次卷动内容一像素。 |
常量 | 值 | 描述 |
---|---|---|
QAbstractItemView::SelectItems
|
0
|
选择单个项。 |
QAbstractItemView::SelectRows
|
1
|
仅选择行。 |
QAbstractItemView::SelectColumns
|
2
|
仅选择列。 |
此枚举指示视图如何响应用户选择:
常量 | 值 | 描述 |
---|---|---|
QAbstractItemView::SingleSelection
|
1
|
当用户选择项时,任何已选中项变为未选中。用户通过按下 Ctrl 键取消对选中项的选择是可能的,当点击选中项时。 |
QAbstractItemView::ContiguousSelection
|
4
|
当用户以通常方式选择项时,清零选定并选中新项。不管怎样,若用户按下 Shift 键点击项,选中 (或取消选中) 当前项和点击项之间的所有项,从属点击项状态。 |
QAbstractItemView::ExtendedSelection
|
3
|
当用户以通常方式选择项时,清零选定并选中新项。不管怎样,若用户按下 Ctrl 键点击项时,触发点击项,而所有其它项保持原样。若用户按下 Shift 键点击项,选中 (或取消选中) 当前项和点击项之间的所有项,从属点击项状态。可以通过拖曳鼠标到多个项之上来选择它们。 |
QAbstractItemView::MultiSelection
|
2
|
当用户以通常方式选择项时,会触发这些项的选定状态,而其它项单独保持。可以通过拖曳鼠标到多个项之上来触发它们。 |
QAbstractItemView::NoSelection
|
0
|
无法选择项。 |
最常用模式为 SingleSelection 和 ExtendedSelection。
描述视图可以处于的不同状态。通常,这只对重实现自己的视图感兴趣。
常量 | 值 | 描述 |
---|---|---|
QAbstractItemView::NoState
|
0
|
这是默认状态。 |
QAbstractItemView::DraggingState
|
1
|
用户正在拖曳项。 |
QAbstractItemView::DragSelectingState
|
2
|
用户正在选择项。 |
QAbstractItemView::EditingState
|
3
|
用户正在 Widget 编辑器中编辑项。 |
QAbstractItemView::ExpandingState
|
4
|
用户正在打开项分支。 |
QAbstractItemView::CollapsingState
|
5
|
用户正在关闭项分支。 |
QAbstractItemView::AnimatingState
|
6
|
项视图正在履行动画。 |
此特性保持是否使用交替颜色绘制背景
若此特性为
true
,将绘制项背景使用
QPalette::Base
and
QPalette::AlternateBase
;否则将绘制项背景使用
QPalette::Base
颜色。
默认情况下,此特性为
false
.
访问函数:
bool | alternatingRowColors () const |
void | setAlternatingRowColors (bool enable ) |
此特性保持是否在拖拽移动事件中启用自动卷动
若此特性被设为 true (默认), QAbstractItemView 自动卷动视图内容,若用户在视口边缘 16 像素内拖曳。若当前项改变,那么视图将自动滚动以确保当前项完全可见。
此特性才工作,若视口接受掉落。通过将此特性设为 false 以关闭自动卷动。
访问函数:
bool | hasAutoScroll () const |
void | setAutoScroll (bool enable ) |
此特性保持区域的大小当触发自动卷动时
此特性控制视口边缘触发自动滚动的区域大小。默认值为 16 像素。
访问函数:
int | autoScrollMargin () const |
void | setAutoScrollMargin (int margin ) |
此特性保持将默认用于 QAbstractItemView::drag() 的掉落动作
若特性未设置,掉落动作为 CopyAction 当支持的动作支持 CopyAction 时。
访问函数:
Qt::DropAction | defaultDropAction () const |
void | setDefaultDropAction (Qt::DropAction dropAction ) |
另请参阅 showDropIndicator and dragDropOverwriteMode .
此特性保持视图将进行拖放事件行动
访问函数:
QAbstractItemView::DragDropMode | dragDropMode () const |
void | setDragDropMode (QAbstractItemView::DragDropMode behavior ) |
另请参阅 showDropIndicator and dragDropOverwriteMode .
此特性保持视图的拖放行为
若其值为
true
,选中数据将覆写现有项数据当掉落时,而移动数据时将清除项。若其值为
false
,选中数据将插入作为新项当数据掉落时。当数据移动时,项也被移除。
默认值为
false
,作为在
QListView
and
QTreeView
子类。在
QTableView
子类,另一方面,特性已被设为
true
.
注意:这并非旨在阻止项覆写。模型的 flags() 实现应做到这点,通过不返回 Qt::ItemIsDropEnabled .
访问函数:
bool | dragDropOverwriteMode () const |
void | setDragDropOverwriteMode (bool overwrite ) |
另请参阅 dragDropMode .
此特性保持视图是否支持拖拽其自己的项
访问函数:
bool | dragEnabled () const |
void | setDragEnabled (bool enable ) |
另请参阅 showDropIndicator , DragDropMode , dragDropOverwriteMode ,和 acceptDrops .
此特性保持动作将初启项编辑
This property is a selection of flags defined by EditTrigger , combined using the OR operator. The view will only initiate the editing of an item if the action performed is set in this property.
访问函数:
QAbstractItemView::EditTriggers | editTriggers () const |
void | setEditTriggers (QAbstractItemView::EditTriggers triggers ) |
视图如何在水平方向卷动其内容
此特性控制视图如何水平卷动其内容。卷动可以按像素或按项进行。它的默认值来自样式凭借 QStyle::SH_ItemView_ScrollMode 样式提示。
访问函数:
QAbstractItemView::ScrollMode | horizontalScrollMode () const |
void | setHorizontalScrollMode (QAbstractItemView::ScrollMode mode ) |
void | resetHorizontalScrollMode () |
此特性保持项图标的大小
设置此特性将导致再次布置项,当视图可见时。
访问函数:
QSize | iconSize () const |
void | setIconSize (const QSize & size ) |
通知程序信号:
void | iconSizeChanged (const QSize & size ) |
此特性保持视图使用的选定行为
此特性保持是否按单项、单行或单列进行选择。
访问函数:
QAbstractItemView::SelectionBehavior | selectionBehavior () const |
void | setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior ) |
另请参阅 SelectionMode and SelectionBehavior .
此特性保持在哪种选择模式下操作视图
此特性控制用户是否可以选择一个或多个项,和在多项选定中,选定是否必须为连续范围项。
访问函数:
QAbstractItemView::SelectionMode | selectionMode () const |
void | setSelectionMode (QAbstractItemView::SelectionMode mode ) |
另请参阅 SelectionMode and SelectionBehavior .
此特性保持是否展示掉落指示器,当拖放项时。
访问函数:
bool | showDropIndicator () const |
void | setDropIndicatorShown (bool enable ) |
另请参阅 dragEnabled , DragDropMode , dragDropOverwriteMode ,和 acceptDrops .
此特性保持采用 tab 和 backtab 的项导航是否被启用。
访问函数:
bool | tabKeyNavigation () const |
void | setTabKeyNavigation (bool enable ) |
此特性保持 ... 在省略文本中的位置。
所有项视图的默认值为 Qt::ElideRight .
访问函数:
Qt::TextElideMode | textElideMode () const |
void | setTextElideMode (Qt::TextElideMode mode ) |
视图如何在垂直方向卷动其内容
此特性控制视图如何垂直卷动其内容。卷动可以按每像素或每项进行。它的默认值来自样式凭借 QStyle::SH_ItemView_ScrollMode 样式提示。
访问函数:
QAbstractItemView::ScrollMode | verticalScrollMode () const |
void | setVerticalScrollMode (QAbstractItemView::ScrollMode mode ) |
void | resetVerticalScrollMode () |
[explicit]
QAbstractItemView::
QAbstractItemView
(
QWidget
*
parent
= nullptr)
构造抽象项视图采用给定 parent .
[virtual noexcept]
QAbstractItemView::
~QAbstractItemView
()
销毁视图。
[signal]
void
QAbstractItemView::
activated
(const
QModelIndex
&
index
)
此信号被发射当项指定通过 index is activated by the user. How to activate items depends on the platform; e.g., by single- or double-clicking the item, or by pressing the Return or Enter key when the item is current.
另请参阅 clicked (), doubleClicked (), entered (),和 pressed ().
[slot]
void
QAbstractItemView::
clearSelection
()
取消所有选中项的选择。当前索引不会改变。
另请参阅 setSelection () 和 selectAll ().
[signal]
void
QAbstractItemView::
clicked
(const
QModelIndex
&
index
)
This signal is emitted when a mouse button is left-clicked. The item the mouse was clicked on is specified by index . The signal is only emitted when the index is valid.
另请参阅 activated (), doubleClicked (), entered (),和 pressed ().
[virtual protected slot]
void
QAbstractItemView::
closeEditor
(
QWidget
*
editor
,
QAbstractItemDelegate::EndEditHint
hint
)
关闭给定 editor 并释放它。 hint is used to specify how the view should respond to the end of the editing operation. For example, the hint may indicate that the next item in the view should be opened for editing.
另请参阅 edit () 和 commitData ().
关闭用于项的持久编辑器在给定 index .
另请参阅 openPersistentEditor () 和 isPersistentEditorOpen ().
[virtual protected slot]
void
QAbstractItemView::
commitData
(
QWidget
*
editor
)
提交数据在 editor 到模型。
另请参阅 closeEditor ().
[virtual protected slot]
void
QAbstractItemView::
currentChanged
(const
QModelIndex
&
current
, const
QModelIndex
&
previous
)
This slot is called when a new item becomes the current item. The previous current item is specified by the previous index, and the new item by the current 索引。
If you want to know about changes to items see the dataChanged () 信号。
返回当前项的模型索引。
另请参阅 setCurrentIndex ().
[virtual protected slot]
void
QAbstractItemView::
dataChanged
(const
QModelIndex
&
topLeft
, const
QModelIndex
&
bottomRight
, const
QList
<
int
> &
roles
= QList<int>())
This slot is called when items with the given roles are changed in the model. The changed items are those from topLeft to bottomRight inclusive. If just one item is changed topLeft == bottomRight .
The roles which have been changed can either be an empty container (meaning everything has changed), or a non-empty container with the subset of roles which have changed.
注意: : Qt::ToolTipRole is not honored by dataChanged() in the views provided by Qt.
[protected]
QPoint
QAbstractItemView::
dirtyRegionOffset
() const
返回视图脏区域的偏移。
若使用 scrollDirtyRegion () 和实现 paintEvent () 在子类化的 QAbstractItemView ,应采用由此函数返回的偏移,翻译由描绘事件给出的区域。
另请参阅 scrollDirtyRegion () 和 setDirtyRegion ().
[signal]
void
QAbstractItemView::
doubleClicked
(const
QModelIndex
&
index
)
This signal is emitted when a mouse button is double-clicked. The item the mouse was double-clicked on is specified by index . The signal is only emitted when the index is valid.
另请参阅 clicked () 和 activated ().
[override virtual protected]
void
QAbstractItemView::
dragEnterEvent
(
QDragEnterEvent
*
event
)
重实现: QAbstractScrollArea::dragEnterEvent (QDragEnterEvent *event).
此函数被调用采用给定 event when a drag and drop operation enters the widget. If the drag is over a valid dropping place (e.g. over an item that accepts drops), the event is accepted; otherwise it is ignored.
另请参阅 dropEvent () 和 startDrag ().
[override virtual protected]
void
QAbstractItemView::
dragLeaveEvent
(
QDragLeaveEvent
*
event
)
重实现: QAbstractScrollArea::dragLeaveEvent (QDragLeaveEvent *event).
This function is called when the item being dragged leaves the view. The event describes the state of the drag and drop operation.
[override virtual protected]
void
QAbstractItemView::
dragMoveEvent
(
QDragMoveEvent
*
event
)
重实现: QAbstractScrollArea::dragMoveEvent (QDragMoveEvent *event).
This function is called continuously with the given event during a drag and drop operation over the widget. It can cause the view to scroll if, for example, the user drags a selection to view's right or bottom edge. In this case, the event will be accepted; otherwise it will be ignored.
另请参阅 dropEvent () 和 startDrag ().
[override virtual protected]
void
QAbstractItemView::
dropEvent
(
QDropEvent
*
event
)
重实现: QAbstractScrollArea::dropEvent (QDropEvent *event).
此函数被调用采用给定 event 当掉落事件出现在 Widget 上时。若模型接受事件位置,接受掉落事件;否则,忽略。
另请参阅 startDrag ().
[protected]
QAbstractItemView::DropIndicatorPosition
QAbstractItemView::
dropIndicatorPosition
() const
Returns the position of the drop indicator in relation to the closest item.
[slot]
void
QAbstractItemView::
edit
(const
QModelIndex
&
index
)
Starts editing the item corresponding to the given index 若它可编辑。
Note that this function does not change the current index. Since the current index defines the next and previous items to edit, users may find that keyboard navigation does not work as expected. To provide consistent navigation behavior, call setCurrentIndex () 在此函数采用相同模型索引之前。
另请参阅 QModelIndex::flags ().
[virtual protected]
bool
QAbstractItemView::
edit
(const
QModelIndex
&
index
,
QAbstractItemView::EditTrigger
trigger
,
QEvent
*
event
)
Starts editing the item at
index
, creating an editor if necessary, and returns
true
若视图的
State
现为
EditingState
;否则返回
false
.
The action that caused the editing process is described by trigger , and the associated event is specified by event .
Editing can be forced by specifying the trigger 到 QAbstractItemView::AllEditTriggers .
另请参阅 closeEditor ().
[virtual protected slot]
void
QAbstractItemView::
editorDestroyed
(
QObject
*
editor
)
This function is called when the given editor has been destroyed.
另请参阅 closeEditor ().
[signal]
void
QAbstractItemView::
entered
(const
QModelIndex
&
index
)
This signal is emitted when the mouse cursor enters the item specified by index . Mouse tracking needs to be enabled for this feature to work.
另请参阅 viewportEntered (), activated (), clicked (), doubleClicked (),和 pressed ().
[override virtual protected]
bool
QAbstractItemView::
event
(
QEvent
*
event
)
重实现: QAbstractScrollArea::event (QEvent *event).
[override virtual protected]
bool
QAbstractItemView::
eventFilter
(
QObject
*
object
,
QEvent
*
event
)
重实现: QObject::eventFilter (QObject *watched, QEvent *event).
[protected]
void
QAbstractItemView::
executeDelayedItemsLayout
()
执行调度布局,不等待事件处理开始。
另请参阅 scheduleDelayedItemsLayout ().
[override virtual protected]
void
QAbstractItemView::
focusInEvent
(
QFocusEvent
*
event
)
重实现: QWidget::focusInEvent (QFocusEvent *event).
此函数被调用采用给定 event when the widget obtains the focus. By default, the event is ignored.
另请参阅 setFocus () 和 focusOutEvent ().
[override virtual protected]
bool
QAbstractItemView::
focusNextPrevChild
(
bool
next
)
重实现: QWidget::focusNextPrevChild (bool next).
[override virtual protected]
void
QAbstractItemView::
focusOutEvent
(
QFocusEvent
*
event
)
重实现: QWidget::focusOutEvent (QFocusEvent *event).
此函数被调用采用给定 event when the widget loses the focus. By default, the event is ignored.
另请参阅 clearFocus () 和 focusInEvent ().
[pure virtual protected]
int
QAbstractItemView::
horizontalOffset
() const
返回视图的水平偏移。
在基类中,这是纯虚函数。
另请参阅 verticalOffset ().
[pure virtual]
QModelIndex
QAbstractItemView::
indexAt
(const
QPoint
&
point
) const
Returns the model index of the item at the viewport coordinates point .
在基类中,这是纯虚函数。
另请参阅 visualRect ().
返回用于项的 Widget 在给定 index .
另请参阅 setIndexWidget ().
[virtual protected, since 6.0]
void
QAbstractItemView::
initViewItemOption
(
QStyleOptionViewItem
*
option
) const
初始化 option structure with the view's palette, font, state, alignments etc.
注意: Implementations of this methods should check the version of the structure received, populate all members the implementation is familiar with, and set the version member to the one supported by the implementation before returning.
该函数在 Qt 6.0 引入。
[override virtual protected]
void
QAbstractItemView::
inputMethodEvent
(
QInputMethodEvent
*
event
)
重实现: QWidget::inputMethodEvent (QInputMethodEvent *event).
[override virtual]
QVariant
QAbstractItemView::
inputMethodQuery
(
Qt::InputMethodQuery
query
) const
重实现: QWidget::inputMethodQuery(Qt::InputMethodQuery query) const .
[pure virtual protected]
bool
QAbstractItemView::
isIndexHidden
(const
QModelIndex
&
index
) const
返回
true
若项引用通过给定
index
is hidden in the view, otherwise returns
false
.
Hiding is a view specific feature. For example in TableView a column can be marked as hidden or a row in the TreeView .
在基类中,这是纯虚函数。
返回项是否打开持久编辑器在索引 index .
另请参阅 openPersistentEditor () 和 closePersistentEditor ().
Returns the item delegate used by this view and model. This is either one set with setItemDelegate (), or the default one.
另请参阅 setItemDelegate ().
返回用于此视图的项委托和模型为给定 column 。可以调用 itemDelegate () to get a pointer to the current delegate for a given index.
另请参阅 setItemDelegateForColumn (), itemDelegateForRow (),和 itemDelegate ().
[virtual, since 6.0]
QAbstractItemDelegate
*QAbstractItemView::
itemDelegateForIndex
(const
QModelIndex
&
index
) const
返回用于此视图的项委托和模型为给定 index .
该函数在 Qt 6.0 引入。
另请参阅 setItemDelegate (), setItemDelegateForRow (),和 setItemDelegateForColumn ().
返回用于此视图的项委托和模型为给定
row
,或
nullptr
if no delegate has been assigned. You can call
itemDelegate
() to get a pointer to the current delegate for a given index.
另请参阅 setItemDelegateForRow (), itemDelegateForColumn (),和 setItemDelegate ().
[override virtual protected]
void
QAbstractItemView::
keyPressEvent
(
QKeyEvent
*
event
)
重实现: QAbstractScrollArea::keyPressEvent (QKeyEvent *e).
此函数被调用采用给定 event when a key event is sent to the widget. The default implementation handles basic cursor movement, e.g. Up, Down, Left, Right, Home, PageUp, and PageDown; the activated () signal is emitted if the current index is valid and the activation key is pressed (e.g. Enter or Return, depending on the platform). This function is where editing is initiated by key press, e.g. if F2 is pressed.
另请参阅 edit (), moveCursor (), keyboardSearch (),和 tabKeyNavigation .
[virtual]
void
QAbstractItemView::
keyboardSearch
(const
QString
&
search
)
Moves to and selects the item best matching the string search . If no item is found nothing happens.
In the default implementation, the search is reset if search is empty, or the time interval since the last search has exceeded QApplication::keyboardInputInterval ().
返回此视图呈现的模型。
另请参阅 setModel ().
[override virtual protected]
void
QAbstractItemView::
mouseDoubleClickEvent
(
QMouseEvent
*
event
)
重实现: QAbstractScrollArea::mouseDoubleClickEvent (QMouseEvent *e).
此函数被调用采用给定 event when a mouse button is double clicked inside the widget. If the double-click is on a valid item it emits the doubleClicked () signal and calls edit () on the item.
[override virtual protected]
void
QAbstractItemView::
mouseMoveEvent
(
QMouseEvent
*
event
)
重实现: QAbstractScrollArea::mouseMoveEvent (QMouseEvent *e).
此函数被调用采用给定 event when a mouse move event is sent to the widget. If a selection is in progress and new items are moved over the selection is extended; if a drag is in progress it is continued.
[override virtual protected]
void
QAbstractItemView::
mousePressEvent
(
QMouseEvent
*
event
)
重实现: QAbstractScrollArea::mousePressEvent (QMouseEvent *e).
此函数被调用采用给定 event when a mouse button is pressed while the cursor is inside the widget. If a valid item is pressed on it is made into the current item. This function emits the pressed () 信号。
[override virtual protected]
void
QAbstractItemView::
mouseReleaseEvent
(
QMouseEvent
*
event
)
重实现: QAbstractScrollArea::mouseReleaseEvent (QMouseEvent *e).
此函数被调用采用给定 event when a mouse button is released, after a mouse press event on the widget. If a user presses the mouse inside your widget and then drags the mouse to another location before releasing the mouse button, your widget receives the release event. The function will emit the clicked () signal if an item was being pressed.
[pure virtual protected]
QModelIndex
QAbstractItemView::
moveCursor
(
QAbstractItemView::CursorAction
cursorAction
,
Qt::KeyboardModifiers
modifiers
)
返回 QModelIndex 对象指向下一视图对象,基于给定 cursorAction and keyboard modifiers specified by modifiers .
在基类中,这是纯虚函数。
Opens a persistent editor on the item at the given index . If no editor exists, the delegate will create a new editor.
另请参阅 closePersistentEditor () 和 isPersistentEditorOpen ().
[signal]
void
QAbstractItemView::
pressed
(const
QModelIndex
&
index
)
This signal is emitted when a mouse button is pressed. The item the mouse was pressed on is specified by index . The signal is only emitted when the index is valid.
使用 QGuiApplication::mouseButtons () function to get the state of the mouse buttons.
另请参阅 activated (), clicked (), doubleClicked (),和 entered ().
[virtual slot]
void
QAbstractItemView::
reset
()
重置视图的内部状态。
警告: This function will reset open editors, scroll bar positions, selections, etc. Existing changes will not be committed. If you would like to save your changes when resetting the view, you can reimplement this function, commit your changes, and then call the superclass' implementation.
[override virtual protected]
void
QAbstractItemView::
resizeEvent
(
QResizeEvent
*
event
)
重实现: QAbstractScrollArea::resizeEvent (QResizeEvent *event).
此函数被调用采用给定 event 当重置大小事件被发送给 Widget 时。
另请参阅 QWidget::resizeEvent ().
Returns the model index of the model's root item. The root item is the parent item to the view's toplevel items. The root can be invalid.
另请参阅 setRootIndex ().
[virtual protected slot]
void
QAbstractItemView::
rowsAboutToBeRemoved
(const
QModelIndex
&
parent
,
int
start
,
int
end
)
This slot is called when rows are about to be removed. The deleted rows are those under the given parent from start to end 包括在内。
另请参阅 rowsInserted ().
[virtual protected slot]
void
QAbstractItemView::
rowsInserted
(const
QModelIndex
&
parent
,
int
start
,
int
end
)
This slot is called when rows are inserted. The new rows are those under the given parent from start to end inclusive. The base class implementation calls fetchMore() on the model to check for more data.
另请参阅 rowsAboutToBeRemoved ().
[protected]
void
QAbstractItemView::
scheduleDelayedItemsLayout
()
Schedules a layout of the items in the view to be executed when the event processing starts.
Even if scheduleDelayedItemsLayout() is called multiple times before events are processed, the view will only do the layout once.
另请参阅 executeDelayedItemsLayout ().
[protected]
void
QAbstractItemView::
scrollDirtyRegion
(
int
dx
,
int
dy
)
准备卷动视图按 ( dx , dy ) 像素通过沿相反方向移动脏区域。只需调用此函数,若在视图子类中实现卷动视口。
若实现 scrollContentsBy () 在子类化的 QAbstractItemView ,调用此函数先于调用 QWidget::scroll () 在视口。另外,仅仅调用 update ().
另请参阅 scrollContentsBy (), dirtyRegionOffset (),和 setDirtyRegion ().
[pure virtual]
void
QAbstractItemView::
scrollTo
(const
QModelIndex
&
index
,
QAbstractItemView::ScrollHint
hint
= EnsureVisible)
卷动视图,若有必要确保项在 index 可见。视图将试着定位项根据给定 hint .
在基类中,这是纯虚函数。
[slot]
void
QAbstractItemView::
scrollToBottom
()
卷动视图到底部。
另请参阅 scrollTo () 和 scrollToTop ().
[slot]
void
QAbstractItemView::
scrollToTop
()
卷动视图到顶部。
另请参阅 scrollTo () 和 scrollToBottom ().
[virtual slot]
void
QAbstractItemView::
selectAll
()
Selects all items in the view. This function will use the selection behavior set on the view when selecting.
另请参阅 setSelection (), selectedIndexes (),和 clearSelection ().
[virtual protected]
QModelIndexList
QAbstractItemView::
selectedIndexes
() const
This convenience function returns a list of all selected and non-hidden item indexes in the view. The list contains no duplicates, and is not sorted.
另请参阅 QItemSelectionModel::selectedIndexes ().
[virtual protected slot]
void
QAbstractItemView::
selectionChanged
(const
QItemSelection
&
selected
, const
QItemSelection
&
deselected
)
This slot is called when the selection is changed. The previous selection (which may be empty), is specified by deselected , and the new selection by selected .
另请参阅 setSelection ().
[virtual protected]
QItemSelectionModel::SelectionFlags
QAbstractItemView::
selectionCommand
(const
QModelIndex
&
index
, const
QEvent
*
event
= nullptr) const
Returns the SelectionFlags to be used when updating a selection model for the specified
index
. The result depends on the current
selectionMode
(), and on the user input event
event
, which can be
nullptr
.
重实现此函数以定义自己的选择行为。
另请参阅 setSelection ().
返回当前选定模型。
另请参阅 setSelectionModel () 和 selectedIndexes ().
[slot]
void
QAbstractItemView::
setCurrentIndex
(const
QModelIndex
&
index
)
将当前项设为是项在 index .
除非当前选定方式为 NoSelection ,项也会被选中。注意:此函数还会更新用户履行任何新选定的起始位置。
要把项设为当前项而不选择它,调用
selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
另请参阅 currentIndex (), currentChanged (),和 selectionMode .
[protected]
void
QAbstractItemView::
setDirtyRegion
(const
QRegion
&
region
)
标记给定 region 为脏并调度它以更新。只需调用此函数,若正在实现自己的视图子类。
另请参阅 scrollDirtyRegion () 和 dirtyRegionOffset ().
设置给定 widget 对于项在给定 index ,将 Widget 的所有权传递给视口。
若 index 无效 (如:若传递根索引),此函数什么都不做。
给定 widget 's autoFillBackground property must be set to true, otherwise the widget's background will be transparent, showing both the model data and the item at the given index .
If index widget A is replaced with index widget B, index widget A will be deleted. For example, in the code snippet below, the QLineEdit 对象将被删除。
setIndexWidget(index, new QLineEdit); ... setIndexWidget(index, new QTextEdit);
This function should only be used to display static content within the visible area corresponding to an item of data. If you want to display custom dynamic content or implement a custom editor widget, subclass QStyledItemDelegate 代替。
另请参阅 indexWidget () 和 委托类 .
将此视图及其模型的项委托设为 delegate . This is useful if you want complete control over the editing and display of items.
任何现有委托将被移除,但不被删除。 QAbstractItemView 未拥有所有权对于 delegate .
警告: You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor () signal, and attempt to access, modify or close an editor that has already been closed.
另请参阅 itemDelegate ().
设置给定项 delegate used by this view and model for the given column . All items on column will be drawn and managed by delegate instead of using the default delegate (i.e., itemDelegate ()).
Any existing column delegate for column will be removed, but not deleted. QAbstractItemView 未拥有所有权对于 delegate .
注意: If a delegate has been assigned to both a row and a column, the row delegate will take precedence and manage the intersecting cell index.
警告: You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor () signal, and attempt to access, modify or close an editor that has already been closed.
另请参阅 itemDelegateForColumn (), setItemDelegateForRow (),和 itemDelegate ().
设置给定项 delegate used by this view and model for the given row . All items on row will be drawn and managed by delegate instead of using the default delegate (i.e., itemDelegate ()).
Any existing row delegate for row will be removed, but not deleted. QAbstractItemView 未拥有所有权对于 delegate .
注意: If a delegate has been assigned to both a row and a column, the row delegate (i.e., this delegate) will take precedence and manage the intersecting cell index.
警告: You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the closeEditor () signal, and attempt to access, modify or close an editor that has already been closed.
另请参阅 itemDelegateForRow (), setItemDelegateForColumn (),和 itemDelegate ().
[virtual]
void
QAbstractItemView::
setModel
(
QAbstractItemModel
*
model
)
设置 model 为要呈现视图。
This function will create and set a new selection model, replacing any model that was previously set with setSelectionModel (). However, the old selection model will not be deleted as it may be shared between several views. We recommend that you delete the old selection model if it is no longer required. This is done with the following code:
QItemSelectionModel *m = view->selectionModel(); view->setModel(new model); delete m;
If both the old model and the old selection model do not have parents, or if their parents are long-lived objects, it may be preferable to call their deleteLater () functions to explicitly delete them.
The view does not take ownership of the model unless it is the model's parent object because the model may be shared between many different views.
另请参阅 model (), selectionModel (),和 setSelectionModel ().
[virtual slot]
void
QAbstractItemView::
setRootIndex
(const
QModelIndex
&
index
)
Sets the root item to the item at the given index .
另请参阅 rootIndex ().
[pure virtual protected]
void
QAbstractItemView::
setSelection
(const
QRect
&
rect
,
QItemSelectionModel::SelectionFlags
flags
)
应用选定 flags to the items in or touched by the rectangle, rect .
When implementing your own itemview setSelection should call selectionModel ()->select(selection, flags) where selection is either an empty QModelIndex 或 QItemSelection that contains all items that are contained in rect .
另请参阅 selectionCommand () 和 selectedIndexes ().
[virtual]
void
QAbstractItemView::
setSelectionModel
(
QItemSelectionModel
*
selectionModel
)
Sets the current selection model to the given selectionModel .
Note that, if you call setModel () after this function, the given selectionModel will be replaced by one created by the view.
注意: It is up to the application to delete the old selection model if it is no longer needed; i.e., if it is not being used by other views. This will happen automatically when its parent object is deleted. However, if it does not have a parent, or if the parent is a long-lived object, it may be preferable to call its deleteLater () function to explicitly delete it.
另请参阅 selectionModel (), setModel (),和 clearSelection ().
[protected]
void
QAbstractItemView::
setState
(
QAbstractItemView::State
state
)
将项视图的状态设为给定 state .
另请参阅 state ().
[virtual]
int
QAbstractItemView::
sizeHintForColumn
(
int
column
) const
返回宽度大小提示为指定 column 或 -1 若没有模型。
此函数用于具有水平 Header 头的视图,以查找 Header 头区间的大小提示基于内容为给定 column .
另请参阅 sizeHintForRow ().
返回大小提示为项采用指定 index 或无效大小对于无效索引。
另请参阅 sizeHintForRow () 和 sizeHintForColumn ().
[virtual]
int
QAbstractItemView::
sizeHintForRow
(
int
row
) const
返回高度大小提示为指定 row 或 -1 若没有模型。
The returned height is calculated using the size hints of the given row 's items, i.e. the returned value is the maximum height among the items. Note that to control the height of a row, you must reimplement the QAbstractItemDelegate::sizeHint () 函数。
This function is used in views with a vertical header to find the size hint for a header section based on the contents of the given row .
另请参阅 sizeHintForColumn ().
[virtual protected]
void
QAbstractItemView::
startDrag
(
Qt::DropActions
supportedActions
)
开始拖拽通过调用 drag->exec() 使用给定 supportedActions .
[protected]
QAbstractItemView::State
QAbstractItemView::
state
() const
返回项视图的状态。
另请参阅 setState ().
[override virtual protected]
void
QAbstractItemView::
timerEvent
(
QTimerEvent
*
event
)
重实现: QObject::timerEvent (QTimerEvent *event).
此函数被调用采用给定 event 当计时器事件被发送给 Widget 时。
另请参阅 QObject::timerEvent ().
[slot]
void
QAbstractItemView::
update
(const
QModelIndex
&
index
)
更新占用区域通过给定 index .
[virtual protected slot]
void
QAbstractItemView::
updateGeometries
()
更新视图子级 Widget 的几何体。
[pure virtual protected]
int
QAbstractItemView::
verticalOffset
() const
返回视图的垂直偏移。
在基类中,这是纯虚函数。
另请参阅 horizontalOffset ().
[signal]
void
QAbstractItemView::
viewportEntered
()
This signal is emitted when the mouse cursor enters the viewport. Mouse tracking needs to be enabled for this feature to work.
另请参阅 entered ().
[override virtual protected]
bool
QAbstractItemView::
viewportEvent
(
QEvent
*
event
)
重实现: QAbstractScrollArea::viewportEvent (QEvent *event).
此函数用于处理工具提示和 What's This? 模式,若给定 event 是 QEvent::ToolTip ,或 QEvent::WhatsThis 。它将所有其它事件传递到其基类 viewportEvent() 处理程序。
返回
true
if
event
已被识别并处理;否则,返回
false
.
[override virtual protected]
QSize
QAbstractItemView::
viewportSizeHint
() const
重实现: QAbstractScrollArea::viewportSizeHint() const .
[pure virtual]
QRect
QAbstractItemView::
visualRect
(const
QModelIndex
&
index
) const
返回项所占据的视口矩形为 index .
若项显示在多个区域,那么 visualRect 应返回包含索引的首要区域,而不是索引可能环绕、触摸或导致绘制的完整区域。
在基类中,这是纯虚函数。
另请参阅 indexAt () 和 visualRegionForSelection ().
[pure virtual protected]
QRegion
QAbstractItemView::
visualRegionForSelection
(const
QItemSelection
&
selection
) const
返回来自项视口的区域在给定 selection .
在基类中,这是纯虚函数。
另请参阅 visualRect () 和 selectedIndexes ().