QWebElementCollection Class Reference

[QtWebKit module]

该QWebElementCollection类表示网络元素的集合。More…

Methods

  • __init__ (self)
  • __init__ (self, QWebElement contextElement, QString query)
  • __init__ (self, QWebElementCollection)
  • append (self, QWebElementCollection collection)
  • QWebElement at (self, int i)
  • int count (self)
  • QWebElement first (self)
  • QWebElement last (self)
  • list-of-QWebElement toList (self)

Special Methods

  • QWebElementCollection __add__ (self, QWebElementCollection other)
  • QWebElement __getitem__ (self, int i)
  • QWebElementCollection __iadd__ (self, QWebElementCollection other)
  • __len__ (self)

Detailed Description

该QWebElementCollection类表示网络元素的集合。

在一个文档元素可以使用被选择QWebElement.findAll() ,或使用QWebElement构造函数。该集合是通过选择符合指定CSS选择器表达式,文档中的所有元素组成的。

选择的元素的数目是通过提供count()属性。单个元素可以通过使用索引来检索at( ) 。

它也可以遍历使用Qt的foreach宏集合中的所有元素:

  1. QWebElementCollection collection = document.findAll("p");
  2. foreach ([QWebElement]($docs-qwebelement.html) paraElement, collection) {
  3. ...
  4. }

Method Documentation

  1. QWebElementCollection.__init__ (self)

构造一个空的集合。

  1. QWebElementCollection.__init__ (self, QWebElement contextElement, QString query)

从构造的子元素的列表元素的集合contextElement匹配指定CSS选择器query

  1. QWebElementCollection.__init__ (self, QWebElementCollection)

构造的副本other

  1. QWebElementCollection.append (self, QWebElementCollection collection)

通过附加的所有项目扩展集合other

结果集合可能包含重复的元素。

See also operator+=( ) 。

  1. QWebElement QWebElementCollection.at (self, int i)

[

返回元素的索引位置i在该集合中。

  1. int QWebElementCollection.count (self)

返回集合中的元素数目。

]($docs-qwebelement.html)

  1. QWebElement QWebElementCollection.first (self)

[

返回集合中的第一个元素。

]($docs-qwebelement.html)

See also last( )operator[]( )at()和count( ) 。

  1. QWebElement QWebElementCollection.last (self)

[

返回集合中的最后一个元素。

]($docs-qwebelement.html)

See also first( )operator[]( )at()和count( ) 。

  1. list-of-QWebElement QWebElementCollection.toList (self)

返回QList对象包含在这个集合中的元素。

  1. QWebElementCollection QWebElementCollection.__add__ (self, QWebElementCollection other)

  1. QWebElement QWebElementCollection.__getitem__ (self, int i)

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

[

  1. QWebElementCollection.__len__ (self)

](qwebelementcollection.html)