QItemSelection Class Reference

[QtGui module]

该QItemSelection类管理有关模型中的选定项目的信息。More…

Methods

  • __init__ (self)
  • __init__ (self, QModelIndex topLeft, QModelIndex bottomRight)
  • __init__ (self, QItemSelection)
  • append (self, QItemSelectionRange range)
  • clear (self)
  • bool contains (self, QModelIndex index)
  • int count (self, QItemSelectionRange range)
  • int count (self)
  • QItemSelectionRange first (self)
  • list-of-QModelIndex indexes (self)
  • int indexOf (self, QItemSelectionRange value, int from = 0)
  • insert (self, int i, QItemSelectionRange range)
  • bool isEmpty (self)
  • QItemSelectionRange last (self)
  • int lastIndexOf (self, QItemSelectionRange value, int from = -1)
  • merge (self, QItemSelection other, QItemSelectionModel.SelectionFlags command)
  • move (self, int from, int to)
  • prepend (self, QItemSelectionRange range)
  • int removeAll (self, QItemSelectionRange range)
  • removeAt (self, int i)
  • replace (self, int i, QItemSelectionRange range)
  • select (self, QModelIndex topLeft, QModelIndex bottomRight)
  • swap (self, int i, int j)
  • QItemSelectionRange takeAt (self, int i)
  • QItemSelectionRange takeFirst (self)
  • QItemSelectionRange takeLast (self)

Static Methods

  • split (QItemSelectionRange range, QItemSelectionRange other, QItemSelection result)

Special Methods

  • int __contains__ (self, QModelIndex index)
  • __delitem__ (self, int i)
  • __delitem__ (self, slice slice)
  • bool __eq__ (self, QItemSelection other)
  • QItemSelectionRange __getitem__ (self, int i)
  • QItemSelection __getitem__ (self, slice slice)
  • QItemSelection __iadd__ (self, QItemSelection other)
  • QItemSelection __iadd__ (self, QItemSelectionRange value)
  • __len__ (self)
  • bool __ne__ (self, QItemSelection other)
  • __setitem__ (self, int i, QItemSelectionRange range)
  • __setitem__ (self, slice slice, QItemSelection list)

Detailed Description

该QItemSelection类管理有关模型中的选定项目的信息。

甲QItemSelection描述在已经由用户选择的模式中的项目。一个QItemSelection基本上是选择范围列表,请参阅QItemSelectionRange。它提供了用于创建和操作选择,并从模型中选择一个范围内的项目。

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

项目选择可以构造并初始化为包含范围从现有的模型项目。下面的示例构造一个包含从给定的各类物品的选择model,开始在topLeft,和结束的bottomRight

  1. QItemSelection *selection = new QItemSelection(topLeft, bottomRight);

一个空的项目选择可以构造,后来填充的要求。因此,如果模型要当我们构建了项目选择为不可用,我们可以重写上面的代码中的方法如下:

  1. QItemSelection *selection = new QItemSelection();
  2. ...
  3. selection->select(topLeft, bottomRight);

QItemSelection节省内存,并避免不必要的工作,通过与选择范围工作,而不是记录的模型项目的索引为每个项目中选择。一般来说,这个类的实例将包含非重叠选择范围的列表。

使用merge( )合并一个项目的选择到另一个未做重叠的范围。使用split( )的基础上另外一个选择范围分割一个选择范围为更小的范围。


Method Documentation

  1. QItemSelection.__init__ (self)

构造一个空的选择。

  1. QItemSelection.__init__ (self, QModelIndex topLeft, QModelIndex bottomRight)

构造一个项目选择,从左上角模型项目延伸,由指定的topLeft指数,在右下角项目,由指定的bottomRight

  1. QItemSelection.__init__ (self, QItemSelection)
  1. QItemSelection.append (self, QItemSelectionRange range)
  1. QItemSelection.clear (self)
  1. bool QItemSelection.contains (self, QModelIndex index)

如果选择包含给定的,则返回Trueindex否则返回False 。

  1. int QItemSelection.count (self, QItemSelectionRange range)
  1. int QItemSelection.count (self)
  1. QItemSelectionRange QItemSelection.first (self)

[

  1. list-of-QModelIndex QItemSelection.indexes (self)

返回对应于所选择的项的模型索引的列表。

  1. int QItemSelection.indexOf (self, QItemSelectionRange value, int from = 0)
  1. QItemSelection.insert (self, int i, QItemSelectionRange range)
  1. bool QItemSelection.isEmpty (self)

]($docs-qitemselectionrange.html)

  1. QItemSelectionRange QItemSelection.last (self)

[

  1. int QItemSelection.lastIndexOf (self, QItemSelectionRange value, int from = -1)
  1. QItemSelection.merge (self, QItemSelection other, QItemSelectionModel.SelectionFlags command)

]($docs-qitemselectionrange.html)

合并的other选择与此QItemSelection使用command给出。这种方法保证了没有范围是重叠的。

请注意,只有QItemSelectionModel.SelectQItemSelectionModel.DeselectQItemSelectionModel.Toggle被支持。

See also split( ) 。

  1. QItemSelection.move (self, int from, int to)
  1. QItemSelection.prepend (self, QItemSelectionRange range)
  1. int QItemSelection.removeAll (self, QItemSelectionRange range)
  1. QItemSelection.removeAt (self, int i)
  1. QItemSelection.replace (self, int i, QItemSelectionRange range)
  1. QItemSelection.select (self, QModelIndex topLeft, QModelIndex bottomRight)

添加该范围中的项目,从左上角的模型项上延伸,由指定的topLeft指数,在右下角项目,由指定的bottomRight到列表中。

Note: topLeftbottomRight必须具有相同的父代。

  1. QItemSelection.split (QItemSelectionRange range, QItemSelectionRange other, QItemSelection result)

拆分选择range使用选择other范围。在删除所有项目otherrange并将该结果result。这可以用的语义进行比较subtract的一组操作。

See also merge( ) 。

  1. QItemSelection.swap (self, int i, int j)
  1. QItemSelectionRange QItemSelection.takeAt (self, int i)

  1. QItemSelectionRange QItemSelection.takeFirst (self)

  1. QItemSelectionRange QItemSelection.takeLast (self)

[

  1. int QItemSelection.__contains__ (self, QModelIndex index)
  1. QItemSelection.__delitem__ (self, int i)
  1. QItemSelection.__delitem__ (self, slice slice)
  1. bool QItemSelection.__eq__ (self, QItemSelection other)

]($docs-qitemselectionrange.html)

  1. QItemSelectionRange QItemSelection.__getitem__ (self, int i)

  1. QItemSelection QItemSelection.__getitem__ (self, slice slice)

  1. QItemSelection QItemSelection.__iadd__ (self, QItemSelection other)

  1. QItemSelection QItemSelection.__iadd__ (self, QItemSelectionRange value)

[

  1. QItemSelection.__len__ (self)
  1. bool QItemSelection.__ne__ (self, QItemSelection other)
  1. QItemSelection.__setitem__ (self, int i, QItemSelectionRange range)
  1. QItemSelection.__setitem__ (self, slice slice, QItemSelection list)

]($docs-qitemselection.html)