QItemSelectionModel Class Reference

[QtGui module]

该QItemSelectionModel类跟踪视图的选定项目。More…

继承QObject

Types

  • enum SelectionFlag { NoUpdate, Clear, Select, Deselect, ..., ClearAndSelect }
  • class **[SelectionFlags]($docs-index.htm)**

Methods

  • __init__ (self, QAbstractItemModel model)
  • __init__ (self, QAbstractItemModel model, QObject parent)
  • clear (self)
  • clearSelection (self)
  • bool columnIntersectsSelection (self, int column, QModelIndex parent)
  • QModelIndex currentIndex (self)
  • emitSelectionChanged (self, QItemSelection newSelection, QItemSelection oldSelection)
  • bool hasSelection (self)
  • bool isColumnSelected (self, int column, QModelIndex parent)
  • bool isRowSelected (self, int row, QModelIndex parent)
  • bool isSelected (self, QModelIndex index)
  • QAbstractItemModel model (self)
  • reset (self)
  • bool rowIntersectsSelection (self, int row, QModelIndex parent)
  • select (self, QModelIndex index, SelectionFlags command)
  • select (self, QItemSelection selection, SelectionFlags command)
  • list-of-QModelIndex selectedColumns (self, int row = 0)
  • list-of-QModelIndex selectedIndexes (self)
  • list-of-QModelIndex selectedRows (self, int column = 0)
  • QItemSelection selection (self)
  • setCurrentIndex (self, QModelIndex index, SelectionFlags command)

Qt Signals

  • void currentChanged (const QModelIndex&,const QModelIndex&)
  • void currentColumnChanged (const QModelIndex&,const QModelIndex&)
  • void currentRowChanged (const QModelIndex&,const QModelIndex&)
  • void selectionChanged (const QItemSelection&,const QItemSelection&)

Detailed Description

该QItemSelectionModel类跟踪视图的选定项目。

一个QItemSelectionModel跟踪选定的项目在一个视图或多个视图到同一个模型。它也跟踪当前所选项目的视图中。

该QItemSelectionModel类是一个Model/View Classes并且是Qt的一部分model/view framework

所选择的项目,采用范围存储。每当你要修改的选定项目select( ),并提供任一QItemSelectionQModelIndexQItemSelectionModel.SelectionFlag

该QItemSelectionModel需要一个两层的方法来选择管理,处理已提交双方选定的项目,并且是当前选择的一部分项目。在当前选择的项目是当前交互的选择(例如用橡皮筋选择或键盘移位的选择)的一部分。

要更新当前选定的项目,使用或按位QItemSelectionModel.Current和任何其它的SelectionFlags。如果省略了QItemSelectionModel.Current命令,新的当前选择将被创建,并且前一个加入到整个选择。所有的功能在两个层次上作业,例如, selectedItems ( )将从两个层返回的项目。


Type Documentation

  1. QItemSelectionModel.SelectionFlag

这个枚举变量描述的方式选择模型将被更新。

Constant Value Description
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 选择和电流的组合,提供了方便。
QItemSelectionModel.ToggleCurrent Toggle | Current 切换和电流的组合,提供了方便。
QItemSelectionModel.ClearAndSelect Clear | Select 清除和选择的组合,提供了方便。

该SelectionFlags类型是一个typedef为QFlags\u003cSelectionFlag\u003e 。它存储SelectionFlag值的或组合。


Method Documentation

  1. QItemSelectionModel.__init__ (self, QAbstractItemModel model)

构造一个运行在指定项目的选择模型model

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

parent的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。

构造一个运行在指定项目的选择模型modelparent

  1. QItemSelectionModel.clear (self)

这种方法也是一个Qt槽与C + +的签名void clear()

清除选择模型。发射selectionChanged()和currentChanged( ) 。

  1. QItemSelectionModel.clearSelection (self)

这种方法也是一个Qt槽与C + +的签名void clearSelection()

清除选择中的选择模型。发射selectionChanged( ) 。

这个函数中引入了Qt 4.2中。

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

如果在所选择的任何项目,则返回Truecolumn用给定的parent

  1. QModelIndex QItemSelectionModel.currentIndex (self)

[

返回模型项指数目前的项目,或无效的索引,如果没有当前项目。

]($docs-qmodelindex.html)

See also setCurrentIndex( ) 。

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

比较了两种选择newSelectionoldSelection并发出selectionChanged( )与取消和选定的项目。

  1. bool QItemSelectionModel.hasSelection (self)

返回True如果选择模型中包含的任何选择的范围,否则返回False 。

这个函数中引入了Qt 4.2中。

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

如果所有项目中被选中,则返回Truecolumn用给定的parent

注意,这个函数通常比调用更快isSelected()在同一列中,并且所有的项目不可选择的数据项都被忽略。

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

如果所有项目中被选中,则返回Truerow用给定的parent

注意,这个函数通常比调用更快isSelected()在同一行和所有项目不可选择的数据项都被忽略。

  1. bool QItemSelectionModel.isSelected (self, QModelIndex index)

返回True如果给定的模型项目index被选中。

  1. QAbstractItemModel QItemSelectionModel.model (self)

[

返回由选择模型上操作的项目模型。

  1. QItemSelectionModel.reset (self)

这种方法也是一个Qt槽与C + +的签名void reset()

清除选择模型。不发射任何信号。

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

如果在所选择的任何项目,则返回Truerow用给定的parent

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

这种方法也是一个Qt槽与C + +的签名void select(const QModelIndex&,QItemSelectionModel::SelectionFlags)

]($docs-qabstractitemmodel.html)

选择模型项目index使用指定的command,并发射selectionChanged( ) 。

See also QItemSelectionModel.SelectionFlags

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

这种方法也是一个Qt槽与C + +的签名void select(const QItemSelection&,QItemSelectionModel::SelectionFlags)

选择项目selection使用指定的command,并发射selectionChanged( ) 。

See also QItemSelectionModel.SelectionFlag

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

返回该索引中的给定row对其中所有行被选中的列。

这个函数中引入了Qt 4.2中。

See also selectedIndexes()和selectedRows( ) 。

  1. list-of-QModelIndex QItemSelectionModel.selectedIndexes (self)

返回所有选定的模型项目索引的列表。该列表包含没有重复,并没有排序。

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

返回该索引中的给定column对所有列被选中的行。

这个函数中引入了Qt 4.2中。

See also selectedIndexes()和selectedColumns( ) 。

  1. QItemSelection QItemSelectionModel.selection (self)

[

返回存储在选择模型的选择范围。

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

这种方法也是一个Qt槽与C + +的签名void setCurrentIndex(const QModelIndex&,QItemSelectionModel::SelectionFlags)

]($docs-qitemselection.html)

设定模型项目index为当前项目,并发射currentChanged( ) 。目前项目用于键盘导航和焦点指示,它是独立于任何选定的项目,虽然选择的项目也可以是当前项目。

根据指定的command时,index也可以成为当前选择的一部分。

See also currentIndex()和select( ) 。


Qt Signal Documentation

  1. void currentChanged (const QModelIndex&,const QModelIndex&)

这是该信号的默认超载。

这个信号被发射时的当前项的变化。该previous模型项目指标被替换current指标作为选择的当前项。

请注意,当产品模型被重新设定此信号将不被发射。

See also currentIndex( )setCurrentIndex()和selectionChanged( ) 。

  1. void currentColumnChanged (const QModelIndex&,const QModelIndex&)

这是该信号的默认超载。

这个信号被发射,如果current项目的变化和它的列是不同的列previous目前的项目。

请注意,当产品模型被重新设定此信号将不被发射。

See also currentChanged( )currentRowChanged( )currentIndex()和setCurrentIndex( ) 。

  1. void currentRowChanged (const QModelIndex&,const QModelIndex&)

这是该信号的默认超载。

这个信号被发射,如果current项目的变化和它的行是不同的行previous目前的项目。

请注意,当产品模型被重新设定此信号将不被发射。

See also currentChanged( )currentColumnChanged( )currentIndex()和setCurrentIndex( ) 。

  1. void selectionChanged (const QItemSelection&,const QItemSelection&)

这是该信号的默认超载。

这个信号被发射时的选择改变。在选择的变化被表示为一个项目的选择deselected项目和项目的选择selected项目。

请注意,目前指数从选择独立的变化。还要注意的是,当该项目模型复位这个信号将不发射。

See also select()和currentChanged( ) 。