The QItemSelectionModel 类保持视图选中项的跟踪。 更多...
| 头: | #include <QItemSelectionModel> |
| 继承: | QObject |
| enum | SelectionFlag { NoUpdate, Clear, Select, Deselect, ..., ClearAndSelect } |
| flags | SelectionFlags |
| QItemSelectionModel (QAbstractItemModel * model ) | |
| QItemSelectionModel (QAbstractItemModel * model , QObject * parent ) | |
| virtual | ~QItemSelectionModel () |
| bool | columnIntersectsSelection (int column , const QModelIndex & parent ) const |
| QModelIndex | currentIndex () const |
| bool | hasSelection () const |
| bool | isColumnSelected (int column , const QModelIndex & parent ) const |
| bool | isRowSelected (int row , const QModelIndex & parent ) const |
| bool | isSelected (const QModelIndex & index ) const |
| const QAbstractItemModel * | model () const |
| bool | rowIntersectsSelection (int row , const QModelIndex & parent ) const |
| QModelIndexList | selectedColumns (int row = 0) const |
| QModelIndexList | selectedIndexes () const |
| QModelIndexList | selectedRows (int column = 0) const |
| const QItemSelection | selection () const |
| virtual void | clear () |
| void | clearSelection () |
| virtual void | reset () |
| virtual void | select (const QModelIndex & index , QItemSelectionModel::SelectionFlags 命令 ) |
| virtual void | select (const QItemSelection & selection , QItemSelectionModel::SelectionFlags 命令 ) |
| void | setCurrentIndex (const QModelIndex & index , QItemSelectionModel::SelectionFlags 命令 ) |
| void | currentChanged (const QModelIndex & current , const QModelIndex & previous ) |
| void | currentColumnChanged (const QModelIndex & current , const QModelIndex & previous ) |
| void | currentRowChanged (const QModelIndex & current , const QModelIndex & previous ) |
| void | selectionChanged (const QItemSelection & selected , const QItemSelection & deselected ) |
| void | emitSelectionChanged (const QItemSelection & newSelection , const QItemSelection & oldSelection ) |
The QItemSelectionModel 类保持视图选中项的跟踪。
A QItemSelectionModel keeps track of the selected items in a view, or in several views onto the same model. It also keeps track of the currently selected item in a view.
The QItemSelectionModel 类是一种 模型/视图类 且属于 Qt 的 模型/视图框架 .
选中项使用范围存储。每当想要修改选中项时,使用 select () 和提供 QItemSelection ,或 QModelIndex 和 QItemSelectionModel::SelectionFlag .
The QItemSelectionModel takes a two layer approach to selection management, dealing with both selected items that have been committed and items that are part of the current selection. The current selected items are part of the current interactive selection (for example with rubber-band selection or keyboard-shift selections).
要更新目前的选中项,使用按位 OR 的 QItemSelectionModel::Current 和任何其它 SelectionFlags 。若省略 QItemSelectionModel::Current command, a new current selection will be created, and the previous one added to the whole selection. All functions operate on both layers; for example, selectedItems() will return items from both layers.
另请参阅 模型/视图编程 , QAbstractItemModel ,和 图表范例 .
此枚举描述将更新选定模型的方式。
| 常量 | 值 | 描述 |
|---|---|---|
QItemSelectionModel::NoUpdate
|
0x0000
|
不会做出选择。 |
QItemSelectionModel::Clear
|
0x0001
|
完整选定将被清零。 |
QItemSelectionModel::Select
|
0x0002
|
所有指定索引将被选中。 |
QItemSelectionModel::Deselect
|
0x0004
|
所有指定索引将被取消选择。 |
QItemSelectionModel::Toggle
|
0x0008
|
所有指定索引将根据它们的当前状态被选中或取消选择。 |
QItemSelectionModel::Current
|
0x0010
|
当前选定将被更新。 |
QItemSelectionModel::Rows
|
0x0020
|
将扩展所有索引以跨行。 |
QItemSelectionModel::Columns
|
0x0040
|
将扩展所有索引以跨列。 |
QItemSelectionModel::SelectCurrent
|
Select | Current
|
Select 和 Current 的组合,为方便起见提供。 |
QItemSelectionModel::ToggleCurrent
|
Toggle | Current
|
Toggle 和 Current 的组合,为方便起见提供。 |
QItemSelectionModel::ClearAndSelect
|
Clear | Select
|
Clear 和 Select 的组合,为方便起见提供。 |
SelectionFlags 类型是 typedef 对于 QFlags <SelectionFlag>。它存储 SelectionFlag 值的 OR 组合。
Constructs a selection model that operates on the specified item model .
Constructs a selection model that operates on the specified item model with parent .
[虚拟]
QItemSelectionModel::
~QItemSelectionModel
()
销毁选定模型。
[virtual slot]
void
QItemSelectionModel::
clear
()
清零选定模型。发射 selectionChanged () 和 currentChanged ().
[slot]
void
QItemSelectionModel::
clearSelection
()
Clears the selection in the selection model. Emits selectionChanged ().
该函数在 Qt 4.2 引入。
Returns true if there are any items selected in the column 采用给定 parent .
[signal]
void
QItemSelectionModel::
currentChanged
(const
QModelIndex
&
current
, const
QModelIndex
&
previous
)
此信号被发射每当当前项改变。 previous model item index is replaced by the current index as the selection's current item.
Note that this signal will not be emitted when the item model is reset.
另请参阅 currentIndex (), setCurrentIndex (),和 selectionChanged ().
[signal]
void
QItemSelectionModel::
currentColumnChanged
(const
QModelIndex
&
current
, const
QModelIndex
&
previous
)
此信号发射,若 current item changes and its column is different to the column of the previous 当前项。
Note that this signal will not be emitted when the item model is reset.
另请参阅 currentChanged (), currentRowChanged (), currentIndex (),和 setCurrentIndex ().
Returns the model item index for the current item, or an invalid index if there is no current item.
另请参阅 setCurrentIndex ().
[signal]
void
QItemSelectionModel::
currentRowChanged
(const
QModelIndex
&
current
, const
QModelIndex
&
previous
)
此信号发射,若 current item changes and its row is different to the row of the previous 当前项。
Note that this signal will not be emitted when the item model is reset.
另请参阅 currentChanged (), currentColumnChanged (), currentIndex (),和 setCurrentIndex ().
[protected]
void
QItemSelectionModel::
emitSelectionChanged
(const
QItemSelection
&
newSelection
, const
QItemSelection
&
oldSelection
)
比较 2 选定 newSelection and oldSelection 并发射 selectionChanged () with the deselected and selected items.
Returns true if the selection model contains any selection ranges; otherwise returns false.
该函数在 Qt 4.2 引入。
Returns true if all items are selected in the column 采用给定 parent .
Note that this function is usually faster than calling isSelected () on all items in the same column and that unselectable items are ignored.
Returns true if all items are selected in the row 采用给定 parent .
Note that this function is usually faster than calling isSelected () on all items in the same row and that unselectable items are ignored.
Returns true if the given model item index 被选中。
返回由选定模型操作的项模型。
[virtual slot]
void
QItemSelectionModel::
reset
()
Clears the selection model. Does not emit any signals.
Returns true if there are any items selected in the row 采用给定 parent .
[virtual slot]
void
QItemSelectionModel::
select
(const
QModelIndex
&
index
,
QItemSelectionModel::SelectionFlags
命令
)
选择模型项 index 使用指定 命令 ,和发射 selectionChanged ().
另请参阅 QItemSelectionModel::SelectionFlags .
[virtual slot]
void
QItemSelectionModel::
select
(const
QItemSelection
&
selection
,
QItemSelectionModel::SelectionFlags
命令
)
选择项 selection 使用指定 命令 ,和发射 selectionChanged ().
另请参阅 QItemSelectionModel::SelectionFlag .
返回的索引在给定 row 对于选中所有行的列而言。
该函数在 Qt 4.2 引入。
另请参阅 selectedIndexes () 和 selectedRows ().
返回所有选中模型项索引的列表。列表包含的不重复,且未排序。
返回的索引在给定 column 对于选中所有列的行而言。
该函数在 Qt 4.2 引入。
另请参阅 selectedIndexes () 和 selectedColumns ().
返回存储在选定模型中的选定范围。
[signal]
void
QItemSelectionModel::
selectionChanged
(const
QItemSelection
&
selected
, const
QItemSelection
&
deselected
)
This signal is emitted whenever the selection changes. The change in the selection is represented as an item selection of deselected items and an item selection of selected 项。
Note the that the current index changes independently from the selection. Also note that this signal will not be emitted when the item model is reset.
另请参阅 select () 和 currentChanged ().
[slot]
void
QItemSelectionModel::
setCurrentIndex
(const
QModelIndex
&
index
,
QItemSelectionModel::SelectionFlags
命令
)
Sets the model item index to be the current item, and emits currentChanged (). The current item is used for keyboard navigation and focus indication; it is independent of any selected items, although a selected item can also be the current item.
从属指定 命令 , index 也可以变为当前选定的一部分。
另请参阅 currentIndex () 和 select ().