QItemSelectionModel Class Reference

[ QtGui module]

The QItemSelectionModel class keeps track of a view's selected 项。 更多...

继承 QObject .

类型

方法

Qt Signals


详细描述

The QItemSelectionModel class keeps track of a view's selected 项。

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 class is one of the 模型/视图类 且属于 Qt 的 模型/视图框架 .

The selected items are stored using ranges. Whenever you want to modify the selected items use select () and provide either a 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).

To update the currently selected items, use the bitwise OR of QItemSelectionModel.Current and any of the other SelectionFlags . If you omit the 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.


类型文档编制

QItemSelectionModel.SelectionFlag

This enum describes the way the selection model will be updated.

常量 描述
QItemSelectionModel.NoUpdate 0x0000 No selection will be made.
QItemSelectionModel.Clear 0x0001 The complete selection will be cleared.
QItemSelectionModel.Select 0x0002 All specified indexes will be selected.
QItemSelectionModel.Deselect 0x0004 All specified indexes will be deselected.
QItemSelectionModel.Toggle 0x0008 All specified indexes will be selected or deselected depending on their current state.
QItemSelectionModel.Current 0x0010 The current selection will be updated.
QItemSelectionModel.Rows 0x0020 All indexes will be expanded to span rows.
QItemSelectionModel.Columns 0x0040 All indexes will be expanded to span columns.
QItemSelectionModel.SelectCurrent Select | Current A combination of Select and Current, provided for convenience.
QItemSelectionModel.ToggleCurrent Toggle | Current A combination of Toggle and Current, provided for convenience.
QItemSelectionModel.ClearAndSelect Clear | Select A combination of Clear and Select, provided for convenience.

The SelectionFlags type is a typedef for QFlags <SelectionFlag>. It stores an OR combination of SelectionFlag values.


方法文档编制

QItemSelectionModel.__init__ ( self , QAbstractItemModel   model )

model argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a selection model that operates on the specified item model .

QItemSelectionModel.__init__ ( self , QAbstractItemModel   model , QObject   parent )

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a selection model that operates on the specified item model with parent .

QItemSelectionModel.clear ( self )

This method is also a Qt slot with the C++ signature void clear() .

Clears the selection model. Emits selectionChanged () and currentChanged ().

QItemSelectionModel.clearSelection ( self )

This method is also a Qt slot with the C++ signature void clearSelection() .

Clears the selection in the selection model. Emits selectionChanged ().

该函数在 Qt 4.2 引入。

bool QItemSelectionModel.columnIntersectsSelection ( self , int  column , QModelIndex   parent )

Returns true if there are any items selected in the column with the given parent .

QModelIndex QItemSelectionModel.currentIndex ( self )

Returns the model item index for the current item, or an invalid index if there is no current item.

另请参阅 setCurrentIndex ().

QItemSelectionModel.emitSelectionChanged ( self , QItemSelection   newSelection , QItemSelection   oldSelection )

Compares the two selections newSelection and oldSelection 并发射 selectionChanged () with the deselected and selected items.

bool QItemSelectionModel.hasSelection ( self )

Returns true if the selection model contains any selection ranges; otherwise returns false.

该函数在 Qt 4.2 引入。

bool QItemSelectionModel.isColumnSelected ( self , int  column , QModelIndex   parent )

Returns true if all items are selected in the column with the given parent .

Note that this function is usually faster than calling isSelected () on all items in the same column and that unselectable items are ignored.

bool QItemSelectionModel.isRowSelected ( self , int  row , QModelIndex   parent )

Returns true if all items are selected in the row with the given parent .

Note that this function is usually faster than calling isSelected () on all items in the same row and that unselectable items are ignored.

bool QItemSelectionModel.isSelected ( self , QModelIndex   index )

Returns true if the given model item index is selected.

QAbstractItemModel QItemSelectionModel.model ( self )

Returns the item model operated on by the selection model.

QItemSelectionModel.reset ( self )

This method is also a Qt slot with the C++ signature void reset() .

Clears the selection model. Does not emit any signals.

bool QItemSelectionModel.rowIntersectsSelection ( self , int  row , QModelIndex   parent )

Returns true if there are any items selected in the row with the given parent .

QItemSelectionModel.select ( self , QModelIndex   index , SelectionFlags   command )

This method is also a Qt slot with the C++ signature void select(const QModelIndex&,QItemSelectionModel::SelectionFlags) .

Selects the model item index 使用指定 command , and emits selectionChanged ().

另请参阅 QItemSelectionModel.SelectionFlags .

QItemSelectionModel.select ( self , QItemSelection   selection , SelectionFlags   command )

This method is also a Qt slot with the C++ signature void select(const QItemSelection&,QItemSelectionModel::SelectionFlags) .

Selects the item selection 使用指定 command , and emits selectionChanged ().

另请参阅 QItemSelectionModel.SelectionFlag .

list-of-QModelIndex QItemSelectionModel.selectedColumns ( self , int  row  = 0)

Returns the indexes in the given row for columns where all rows are selected.

该函数在 Qt 4.2 引入。

另请参阅 selectedIndexes () and selectedRows ().

list-of-QModelIndex QItemSelectionModel.selectedIndexes ( self )

Returns a list of all selected model item indexes. The list contains no duplicates, and is not sorted.

list-of-QModelIndex QItemSelectionModel.selectedRows ( self , int  column  = 0)

Returns the indexes in the given column for the rows where all columns are selected.

该函数在 Qt 4.2 引入。

另请参阅 selectedIndexes () and selectedColumns ().

QItemSelection QItemSelectionModel.selection ( self )

Returns the selection ranges stored in the selection model.

QItemSelectionModel.setCurrentIndex ( self , QModelIndex   index , SelectionFlags   command )

This method is also a Qt slot with the C++ signature void setCurrentIndex(const QModelIndex&,QItemSelectionModel::SelectionFlags) .

Sets the model item index to be the current item, and 发射 currentChanged ()。 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.

Depending on the specified command index can also become part of the current selection.

另请参阅 currentIndex () 和 select ().


Qt Signal Documentation

void currentChanged (const QModelIndex&,const QModelIndex&)

This is the default overload of this signal.

此信号被发射每当当前项改变。 上一 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 (), and selectionChanged ().

void currentColumnChanged (const QModelIndex&,const QModelIndex&)

This is the default overload of this signal.

此信号被发射,若 current item changes and its column is different to the column of the 上一 当前项。

Note that this signal will not be emitted when the item model is reset.

另请参阅 currentChanged (), currentRowChanged (), currentIndex (), and setCurrentIndex ().

void currentRowChanged (const QModelIndex&,const QModelIndex&)

This is the default overload of this signal.

此信号被发射,若 current item changes and its row is different to the row of the 上一 current 项。

Note that this signal will not be emitted when the item model is reset.

另请参阅 currentChanged (), currentColumnChanged (), currentIndex (), and setCurrentIndex ().

void selectionChanged (const QItemSelection&,const QItemSelection&)

This is the default overload of this signal.

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 ().